HomeGuidesRecipesAPI
HomeGuidesAPILog In
Guides
These docs are for v10. Click to read the latest docs for v31.

Send to REST Service Action

Infiniti includes the ability to send form data to a REST service, via the "Send to REST Service" action. The action allows you to specify:

  • Endpoint URL
  • HTTP method (defaults to POST)
  • Basic Auth username and password
  • Custom Headers
  • Access token
  • Send as multi-part (true/false)
  • Body document (JSON or XML)

The action provides two outputs:

  • Status (the HTTP response such as "OK", "CREATED")
  • Response (the HTTP response body, if any)

1. Basic Action configuration

The Send to REST Service action can be added to a project in Design, either on the Finish page or as part of a Workflow transition.

The input parameters for the action are as follows:

Input NameDescriptionRequired?
URLThe endpoint of the serviceYes
HTTP MethodThe HTTP method to use for the request. Supported values are "GET", "POST", "PUT", and "PATCH". Defaults to "POST" if not specified.No
Basic Auth UsernameThe username to supply for HTTP Basic Auth, if required by the service.No
Basic Auth PasswordThe password to supply for HTTP Basic Auth, if required by the service.No
Custom HeadersAny custom headers (such as an authorisation token or other special data) to supply as part of the request. Multiple headers can be specified if necessary.No
Send Access TokenTrue/false representing whether to send the user's SSO access token (from e.g. a SAML identity) as an Authorization header for the request.No
Send as MultipartWhether to construct a multi-part request (for example, if the body document will exceed the service's maximum request length).No

2. Sending a body document

The action accepts an optional body document to be sent as the content of the request. If required by the service, this should be included as a template within the project and attached as a Action Document.

1068

Selecting a body document for the REST request

📘

Document type

The Action will automatically detect the type of document supplied (JSON or XML) and configure the request headers appropriately.

🚧

Document counts

Only a single JSON or XML body document can be supplied. If more than one is supplied, either explicitly through "Custom" action document settings, or implicitly through multiple templates being present in the project and not deactivated by conditions, the REST Service action will throw an error.

3. Custom headers

Custom headers, if required by the service, can be supplied using the Custom Header action parameter. Zero or more headers may be specified as a key-value pair, and will be sent as part of the REST request.

4. Using the Status and Response outputs

The Status and Response outputs can be referenced by subsequent Actions, for example to drive the display of a message to the user, or to store the response body in a database for later reference.

5. Sample project

The following section will walk through constructing a project to send some REST data to the https://jsonplaceholder.typicode.com/ test service.

Sample JSON schema

{
  "$schema": "http://json-schema.org/draft-04/schema#", 
  "definitions": {}, 
  "id": "http://example.com/example.json", 
  "properties": {
    "body": {
      "description": "An explanation about the purpose of this instance.", 
      "id": "/properties/body", 
      "type": "string"
    }, 
    "title": {
      "description": "An explanation about the purpose of this instance.", 
      "id": "/properties/title", 
      "type": "string"
    }, 
    "userId": {
      "description": "An explanation about the purpose of this instance.", 
      "id": "/properties/userId", 
      "type": "integer"
    }
  }, 
  "type": "object"
}

Project setup

  1. Create a new project in Design
  2. Import the example.schema.json document as a project template
  3. Create some Text Input questions and map their Answers to the template placeholders
  4. Add a "Send to REST Service" action to the project's Finish page
  5. Supply parameters for the action as follows:
  1. Optionally, set up the Action Documents to pass only the correct document to the Action. If there are no other JSON or XML templates in the project this step is unnecessary, as the default "All" setting will work fine

Related Content

Take a look at the REST Data Source type, to retrieve data posted in a previous form session.