Skip to content

HTTP Response

This page is about the task for returning data from the endpoint. If you are looking to handle the response of the HTTP Request task, please see HTTP Response Handler instead.

You do not typically need to use this task in addition to the HTTP Redirect task. If you are using both, it is best to set up filters to decide which one is used by the endpoint.

The HTTP Response task is typically the last task in an endpoint, and is responsible for defining what data or information is returned to the calling application. There are only 3 required fields to complete for this task. The data format, status code, and the body.

Format

Format simply chooses what data format you're sending back. Your data should match the format you choose, and this may be defined by the application that calls the endpoint. For example, if your application expects JSON, then you should select JSON here.

Status Code

Status Code is an HTTP status code. Typically, if everything went well, this will be 200, or if things went wrong, it will be 400. You can find a full list of status codes on the Mozilla website.

Headers

Multiple Headers can be optionally appended to your http response. Each header can have a Key and one or more Values. For example:

  1. Single Value Header:

    • Key: Location
    • Values: https://example.com
    Location: https://example.com
  2. Multiple Value Header:

    • Key: Link
    • Values: <https://api.example.com/page/1>; rel="prev" <https://api.example.com/page/3>; rel="next"
    Link: <https://api.example.com/page/1>; rel="prev"
    Link: <https://api.example.com/page/3>; rel="next"

TIP

You can view the headers that are set by enabling Debug Mode on your endpoint and examining the Endpoint Task Values Resolved in the metrics.

Body

Finally, the body should be the data you wish to return. This should match the Format you have selected, but otherwise the content is completely flexible.

If you omit this task, a basic response with the status code is returned instead, that looks like the following JSON array:

json
[
  {
    "format": null,
    "statusCode": 200,
    "contentType": null,
    "redirectUrl": null,
    "result": null,
    "success": true
  }
]