Home Search

DriveWorks Pro 22
Send HTTP Request

Send Feedback

Send HTTP Request

The Send HTTP request Task, when applied, will send a REST request to a web service.

This task essentially:

  • Connects DriveWorks to the Internet
  • Enables data to be shared with external services

The following functions exist to help with the creation and processing of the HTTP Request.

Properties

Property NameDescription
Request URLThe URL where the web request should be sent.
  • This should be set to the listening endpoint of the REST service. (e.g. https://maps.googleapis.com/maps/api/distancematrix/xml)
  • Some services may require query string parameters to be added to the URL (e.g.https://maps.googleapis.com/maps/api/distancematrix/xml?origins=Thelwall&destinations=Warrington)
Request VerbThe resource action to perform.

The task will accept any valid request verb; the most common being:

  • POST - mostly used to send data to an external service.
  • GET - mostly used to read data from an external source.
  • PUT - usually used for updating data.
  • DELETE - as you would expect.
  • HEAD - asks for a response identical to a GET request, but without the response body.
  • TRACE - performs a message loop-back test along the path to the target resource.
  • OPTIONS - describes the communication options for the target resource.
  • PATCH - applies partial modifications to a resource.
  • ACCEPT - indicates which content types the client is able to understand.

    See Accept (MDN Web Docs) for more information.

This defaults to GET when the Task is added.

Request Headers (optional)A pipe delimited list of headers to be sent with the request.
  • Each key value pair should be separated with the pipe symbol ( | ) and each pair must separate the key and value with a colon character ( : )
  • For example, the string "content-type:text/xml | Accept:text/json" would represent 2 pairs, with the keys content-type and Accept
  • DriveWorks will automatically set the user agent (DriveWorks + Version Number) but this can be overridden with a user-specified value if required.
Request Body (optional)The HTTP request body.
Request Body cannot be set with a GET or HEAD request; therefore anything entered in this field when these Verbs are set will be omitted from the request.
Response Body Constant Name (optional)The name of the constant to drive the response body to.
When provided with the name of a constant, the task will drive the body of the response received from the REST service to it. This will enable users to process the response to retrieve requested data.
Response Header Constant Name (optional)The name of the constant to drive the response headers to.
When provided with the name of a constant, the task will drive the headers of the response received from the REST service to it. This will enable users to process the response to retrieve requested data.
TitleChanges the Title (not the name) of the task.

Outputs

This task has different types of Outputs. For more information about Outputs see Specification Macros Task Node.

Data Outputs

Output NameDescription
Response BodyThe Body of the response
Response HeadersThe Headers of the response

Status Outputs

This task supports Status Outputs. These can be used to perform different actions depending on what the status outcome of the task is. For more information see Status Outputs in the Task Node Outputs section of Specification Macros Task Node.

The status output navigation is as follows:

Success

  • The request was sent successfully.

Success with Warnings

  • Request was successful, but the server returned an error.
  • HTTP Header is missing colon separator.
  • HTTP Header name was empty.
  • HTTP Header value was empty.
  • HTTP Header was restricted and could not be set.
  • Constant could not be found with name provided.

Failed (one of the following occurred)

  • HTTP Request body could not be set (for non GET / HEAD requests).
  • HTTP Verb was invalid or unsupported.
  • URL protocol was missing or invalid.
  • URL was empty.
  • General error - see Specification report for more information.

Example

When this task is added the properties are static by default.
See How To: Change A Static Property To A Dynamic Property to enable rules to be built on these properties.

Property NameExample RuleExample ResultMeaning
Request URLhttp://www.driveworks.co.uk/http://www.driveworks.co.uk/The website you are requesting data from.
Request Verb"Post"PostUsed to send Data to an external source.
Request Verb"Get"GetUsed to Retrieve Data from an external source.
Request Verb"Put"PutUsed to Update Data.
Request Verb"Delete" DeleteUsed to Delete Data.
Request HeaderDWVariableOAuthReqHeaderDWVariableOAuthReqHeaderHeaders being sent with the request.
Request BodyDWVariableOAuthReqBodyDWVariableOAuthReqBodyThe HTTP request body.
Response Body Constant NameDWConstantResponseBodyDWConstantResponseBodyThe name of the constant to drive the response body to.
Response Header constant NameDWConstantResponseHeaderDWConstantResponseHeaderThe name of the constant to drive the response header to.

The Output results for the example would be:

Output NameOutput Value
Response BodyThis will be the data requested and will usually be formatted as XML or JSON. This is the same data sent to the Constant if one is specified.
Response HeadersThis will usually be formatted as XML or JSON and contains information about how to format the Body. This is the same data sent to the Constant if one is specified.

Google Maps Example

This is to show a practical example of how to use this Task to request information from Google Maps. The set up is available to download with other examples as a Tech Tip.

How The Task Is Set Up

PropertyRule
Request URL"https://maps.googleapis.com/maps/api/distancematrix/xml?origins="& StartingPointReturn&"&destinations=" & DestinationReturn & "&mode="&MethodOfTransportReturn & "&units="&UnitsReturn
Request Verb"GET"

Returned Data

This table shows the data that comes back from this request. This can be directly put into another task using the Data Outputs.

Output NameValue
Response Body
<?xml version="1.0" encoding="UTF-8"?>
<DistanceMatrixResponse>
 <status>OK</status>
 <origin_address>Leeds, UK</<origin_address>
 <destination_address>Manchester, UK</destination_address>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>4023</value>
    <text>1 hour 7 mins</text>
   </duration>
   <distance>
    <value>71829</value>
    <text>44.6 mi</text>
   </<distance>
  </element>
 </row>
</DistanceMatrixResponse>
Response Headers
{"X-XSS-Protection","1; mode=block";"X-Frame-Options","SAMEORIGIN";"Alt-Svc","hq=":443""; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"";"Vary","Accept-Language, Accept-Encoding";"Transfer-Encoding","chunked";"Accept-Ranges","none";"Cache-Control","public, max-age=86400";"Content-Type","application/xml; charset=UTF-8";"Date","Fri, 30 Mar 2018 10:16:12 GMT";"Expires","Sat, 31 Mar 2018 10:16:12 GMT";"Server","mafe";}

Using the Task in a Specification Macro

This task has different types of Outputs. For more information about Outputs see Specification Macros Task Node.

Outputs are only available within Specification Macros. Currently Outputs are not available for Specification Flow.

See Also

How To: Create the Data for a Web Service to Communicate with DriveWorks Autopilot

Connector - Web Service

DriveWorks Tech Tips Portal

Send HTTP Request

Look at how to request data from a web service using the HTTP Request task in DriveWorks. You can also look at how to retrieve data from the result using Xpath.

View all Tech Tips

DriveWorks Tech Tips Portal is available to DriveWorks Pro customers with an active subscription and support contract.

Tech Tips provide cut down projects that highlight specific functionality for faster and more effective learning.

To access the portal:

  1. Go to https://my.driveworks.co.uk/learn/tech-tips/
  2. Login with your DriveWorks Pro account credentials, if asked
  3. Click the Visit Tech Tips Portal button for access

The portal provides a search facility, start typing the name of the Tech Tip (as indicated above) to display the Tip you require.