a!httpResponse() Function

Returns an HTTP Response object for use in a Web API.

Syntax

a!httpResponse( statusCode, headers, body )

  • statusCode (Number(Integer)): The status code of the response. Default is "200" meaning successful completion of the request.

  • headers (List of HttpHeader): A list of headers for the response. Built with a!httpheader(). Header values set using a!scsField() will be ignored.

  • body (Text): The body of the response. This value can be either text or a document. If a document is supplied, default headers will be set and the client browser will attempt to open the document. Some documents, such as images, sound files, and PDFs, can be effectively viewed within your browser window. Other documents, such as Microsoft Office files, may be downloaded for local viewing.

Returns

HTTP Response

Examples

To test these examples, paste them into the expression editor of a Web API object. You can view the test results from within the designer by clicking the Test Request button. You can also view the runtime results in your browser by clicking the URL.

Returning a JSON Body

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
a!httpResponse(
  statusCode: 200,
  headers: {
    a!httpHeader(name: "content-type", value: "application/json")
  },
  body:{
    {
      firstName: "Jane",
      lastName: "Doe",
      age: 35
    },
    {
      firstName: "John",
      lastName: "Smith",
      age: 42
    }
  }
)

Returning a Document as the Body

1
2
3
4
5
6
7
8
a!httpResponse(
  statusCode: 200,
  headers: {
    a!httpHeader(name: "content-type", value: "application/json")
  },
  body: a!iconIndicator("STATUS_WARN")
)

See also: Web APIs, a!httpheader()

Old Versions

There are older versions of this function. You can identify older versions by looking at the name to see if there is a version suffix. If you are using an old version, be sure to refer to the corresponding documentation from the list below.

Old Versions Reason for Update
a!httpResponse_17r4

Can now return documents through Web APIs so that other systems can access Appian documents.

To learn more about how Appian handles this kind of versioning, see the Function and Component Versions page.

FEEDBACK