Output Structure

HTTP Request steps provide a structured output with specific properties:

interface HttpRequestStepOutput {
  ok: boolean; // true if status is 2xx
  status: number; // HTTP status code
  headers: {
    // Response headers
    [key: string]: string;
  };
  body: string | object; // Response body
}

Automatic Response Parsing

The body property type depends on the response Content-Type and request headers:

  1. With Accept: application/json header:
CODE_STEP
// Response body is automatically parsed
const data = HTTP_STEP.output.body.items;
  1. Without Accept: application/json header:
CODE_STEP
// Response body is string, must parse manually if JSON
const data = util.parse(HTTP_STEP.output.body).items;

Accessing Output in Non-Code Steps

In non-code steps like model messages, HTTP request URLs, request bodies, and other configuration fields.

{{HTTP_STEP.output.body}}
{{HTTP_STEP.output.status}}
{{HTTP_STEP.output.ok}}

When the accept header is set to application/json, we can access the body as an object:

{{HTTP_STEP.output.body.items}}