lam.httpRequest

Learn more about the httpRequest Keyword

Invocation

Data transformation must output:

JavaScript

{
  "lam.httpRequest": {
    "method": "POST",
    "url": "https://api.example.com/endpoint",
    "pathParams": { /* optional */ },
    "queryParams": { /* optional */ },
    "headers": { /* optional */ },
    "body": { /* optional */ }
  }
}

JQ

{
  "lam.httpRequest": {
    "method": "POST",
    "url": "https://api.example.com/endpoint",
    "pathParams": { ... },  # optional
    "queryParams": { ... }, # optional
    "headers": { ... },     # optional
    "body": { ... }         # optional
  }
}
Key
Description
Type
Required

method

HTTP method (GET, POST, PUT, DELETE)

String

Yes

url

Destination URL

String

Yes

pathParams

URL path parameters

Object

No

queryParams

URL query parameters

Object

No

headers

HTTP headers

Object

No

body

Request body

Object

No

Functionality

The httpRequest keyword makes an HTTP request to the specified endpoint with the given parameters. The response will be stored in the flow's response object. For multiple parallel requests, see lam.httpRequests.

Examples

JavaScript

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "POST",
      "url": "{{props.baseUrl}}/orders/{{orderId}}/items",
      "pathParams": {
        "orderId": input.orderId
      },
      "headers": {
        "Content-Type": "application/json",
        "Authorization": "Bearer {{props.apiKey}}"
      },
      "body": {
        "quantity": input.quantity,
        "notes": input.notes
      }
    }
  };
}

JQ

.input |
{
  "lam.httpRequest": {
    "method": "POST",
    "url": "{{props.baseUrl}}/orders/{{orderId}}/items",
    "pathParams": {
      "orderId": .orderId
    },
    "headers": {
      "Content-Type": "application/json",
      "Authorization": "Bearer {{props.apiKey}}"
    },
    "body": {
      "quantity": .quantity,
      "notes": .notes
    }
  }
}

Last updated

Was this helpful?