Http Client

Perform an HTTP request to a specified endpoint.

When to use?

Whenever you have some data that you need from a separate web end point, or if perhaps you're trying to update something. This will allow you to perform HTTP requests.

How to use:

  1. Select a Scope type from the drop-down
    • Scope type installation is for the duration of the whole installation and has the longest life span. This is essentially stored on the device.
    • Scope type session is for the duration of the current session. This will persist until the user exits the skill.
    • Scope type request is for the duration of a single request. This is the shortest life span and is useful if you're only interested in a bit of data short term.
  2. From the Parameters drop down, pick where you want to store responses.
    • Storing parameters in the Service level makes them available anywhere else in the service.
    • Storing them at Block level makes them availalbe only in the current block.
  3. In the Result name field enter the name the result will be stored under.
  4. In the Endpoint URL field enter the URL you wish to send the request to.
  5. From the Content type drop-down, select the content type you're expecting to get in the headers. If you're unsure, leave it at Auto.
  6. In the HTTP method drop-down choose between GET, POST, or PUT methods
    • You can cache GET requests by entering a Cache timeout value, numbered in seconds.
    • For POST and PUT requests, you can add a JSON Body to send.
  7. In the Timeout field enter an amount, in seconds, the request can hang for before it is terminated.
  8. In the Headers field you can add HTTP headers, and in the Parameters field you can add URL query parameters (?parameter=value)
  9. The element contains two flows to be executed, depending on the request success: OK and NOK
    • To access the body of the response, use the body property on your result variable. For example, if for Result name you chose row, then you could access the body with ${row.body}
    • To access the HTTP status of the request, use the status attribute on your response, e.g. ${row.status}.
    • For errors, you can access the message with the error parameter, e.g. ${row.error}.

Example of usage

Here's an example of how you might fetch and read the horoscope for any given sign. Start off by using a Set Parameter element to set a parameter called sign to any of the horoscope signs, in lower case. For example, virgo

Next, place an HTTP Query element. Configure it as follows: