Sending Data in the HTTP Request
There are several HTTP methods that can be used in an HTTP request. Each method sends data in the request in a different manner. For example, the GET method uses the query string of the request URI to pass parameter/value pairs. Other methods use the HTTP message body to send data in the request.
The Send HTTP Request activity has three input elements for sending data in a request:
-
PostData — corresponds to the body of the HTTP message. All methods except the GET method accept data in this element.
-
QueryString — corresponds to the query string of the request URI. You can use this input element to dynamically construct the query string using an XPath expression when you do not know the names or number of input parameters for the request until the activity executes.
-
Parameters — corresponds to parameters defined in the Parameters field on the Configuration tab. This is useful if you have a fixed set of parameters that you send with the request. For requests that use the GET method, these parameters are passed as the query string of the request URI. For requests that use the POST method, these parameters are usually sent as the body of the HTTP message, but they can also be included in the query string.
For some methods, these input elements are mutually exclusive. For example, for POST requests, you can specify parameters on the Configuration tab and in the parameters input element or you can specify a PostData input element. However, you should not specify both input elements. In the case of a POST request, the PostData input element is ignored when parameters are specified on the Configuration tab.
For GET requests, you can specify parameters on the Configuration tab and in the parameters input element or you can specify a QueryString input element. Typically, if you know the list of parameters for the request, you should configure the parameters on the Configuration tab. If the list of parameters is not known until the activity executes, you should use the QueryString element. However, when all parameters on the Configuration tab are specified as Optional, you can use the QueryString input element instead of the parameters input element (but if any elements in the parameters element contain an expression, the QueryString element is ignored).
Special Characters in HTTP Requests
Depending upon the content type of the data for the request, the request can contain URL-encoded data and the server is expected to decode the data. If this is the case and you want to send special characters such as +, /, or = in your HTTP request, your data string must be URL-encoded if you send the data using the PostData or QueryString input elements. If you send the data using the parameters specified on the Configuration tab, encoding is done automatically.
For example, you want to specify the following PostData:
name=John Smith&address=500 1/2 Main Street
Your PostData input element should result in the following string:
name=John%20Smith&address=500%201%2F2%20Main%20Street
For more information about the URL specification, see http://www.rfc-editor.org/rfc/rfc1738.txt.