Web Service

Connects to a third-party database or endpoint for sending and receiving information.

The supported web connection methods are HTTP GET, HTTP POST, SOAP, and REST.

Properties

Request Type

Select either HTTP or HTTPS.

Web Method

Use 'HTTP GET' for retrieving data. The action cell formats the request URI automatically using its input variables (see Response Output XML Location below). For example: www.example.com/webpage.php?name1=value1&name2=value2
Data is returned using the action cell's output variables.

Use 'HTTP POST' to submit and retrieve data. The action cell's input variable values are included in the body of outgoing messages and output variables are used to store the return values.

Use 'SOAP' to query a remote web service API by formatting and transmitting a custom XML file using the specification defined in a WSDL (Web Service Definition Language) file provided by your organisation. The action cell's Input Variable values are sent in the XML message body and values are returned using output variables.

Note: SOAP APIs are based on the WSDL file and are created by support engineers. Contact your support representative for further information about configuring SOAP request methods.

Use 'REST' to send data to an external web service and to accept returned data from an external web service. The action cell JSON-encodes the input variables (see the example input variables below) and passes this to the select endpoint (see Endpoint Name below).
Data is returned using the action cell's output variables (see the example output variables below).

Server Address

Applies if you are using the HTTP GET, HTTP POST, or SOAP method

Enter the IP address or domain name of the remote server (as a literal value preceded by =, or a string variable).

Request Path

Applies if you are using the HTTP GET, HTTP POST, or SOAP method

Enter the location on the server for the remote web service. For example, </webservices/webpage.php>. Use a literal value preceded by =, or a string variable.

Endpoint Name

Applies if you are using the REST method

Select the endpoint alias to be called from the drop-down list.

Note: Content Guru will add the required URLs to this field. The URL must support https (TLS 1.2). Contact your support representative for further information about adding REST endpoints for your organisation.

Timeout

Applies for all methods

Select the duration for which to wait for a response. If no response received in this time, the Timeout exit route is taken.

Response Output XML Location

Applies if you are using the HTTP GET or HTTP POST method

To speed up lookups, specify where to look for the named output variables in the response XML received from the remote resource. For example, entering </response/response2/getvalue> will look at the bold-highlighted section in the XML tags below:

<?xml version='1.0'?>

  <response>

    <response1>

       <getvalue id='{name1}'>{value}</getvalue>

       <getvalue id='{name2}'>{value}</getvalue>

    </response1>

    <response2>

       <getvalue id='{name1}'>{value}</getvalue>

       <getvalue id='{name2}'>{value}</getvalue>

    </response2>

  </response>

Input Variables

Applies for all methods

Use this section to build a list of variables for passing values to the database or endpoint. In the Name field, enter a label for the parameter to pass (this must match the parameter in the database. In the Value field, provide the variable to pass. Click Add to add the Name/Value pair to the list below.

Example for using the REST method:

These input variables are JSON-encoded and passed to the selected endpoint. In this example, the input variables hold the following data:

Input Variable Name           Value

=source                            Sales

=source ID                        1234567890

=disabled                          False

The Web Service action cell generates the following JSON code, where type is a string which has the value 'flow_event' and created_at is a timestamp in the format YYYY-MM-DDTHH.mm.ss.nnnnnnZ.

{
"type": "flow_event",
"created_at": 2019-03-18T18:02:23.688457Z",
"data":{
"source": "Sales",
"sourceID": "1234567890",
"disabled": "false"
}
}

Note: security headers are added to the request which you can check to verify the request was made by Content Guru.

Output Variables

Applies for all methods

Use this section to build a list of variables for receiving information returned by the database or endpoint. In the Name field, enter a label for the parameter that is being received (this must match the parameter in the database); In the Value field, provide the variable to store the value. Click Add to add the Name/Value pair to the list below.

Example for using the REST method

The Web Services action cell takes the JSON response from the external web service and decodes it into the specified Output Variables. The response must be flat (not nested). The JSON response must also follow these rules:

For example, if the external web service responds with the following, the output variables, the output variables listed below could be added to hold the values.

Response from web service:

{

"id": "234567",

"name": "John Smith"

"sourceID": "400400",

"salesID": "Home Insurance",

}

To store this data, you could add the following output variables:

=id              szid

=name         szname

=sourceID    szsourceID

=salesID      szSalesID

This would be stored in the following Output Variables as

Output Variable Name        Output Variable Value

id                                    234567

name                               John Smith

sourceID                          400400

salesID                            Home Insurance

REST security considerations

Your organisation provides the endpoint callback URI, which must be HTTPS, to protect the authentication credentials in transit.

Each webhook notification will be signed by Content Guru via an X-Hub-Signature header. This allows you to verify that the notification came from Content Guru by decoding the signature.

The value of this X-Hub-Signature header will be computed by creating a signature using the body of the JSON request and a secret value provided by you. The signature is the hexadecimal representation of a SHA-256 signature computed using the HMAC algorithm. The X-Hub-Signature header value starts with the string sha256= followed by the signature.

The event will also contain a timestamp attribute that you can validate, if required.

Exit points

Exit point

Taken

Complete

If the web message has been sent and a response received.

Timeout

If no response is received within the timeout period specified in Timeout.

Request Failed

If there is an error with the request.