Laminar
  • Laminar
  • Platform
    • Overview
    • Getting Started
    • Advanced
      • Workflows
        • Global Workflow Object
        • HTTP Request Batching
        • Workflow Exit Points
        • Invoke Secondary Workflows
      • Configurations
      • Flows
        • Flow Types
          • HTTP Request
          • Data Transformations
        • Supported Languages
      • Managing Notifications
    • Best Practices
    • Keywords
      • lam.resolveThenExecute
      • lam.exit
      • lam.execute
      • lam.asyncExecute
      • lam.httpRequest
      • lam.httpRequests
  • API
    • Executing a Workflow
    • Creating a Configuration
    • Authentication
    • Changelog
  • External Links
    • Book a Demo
    • Sign In
Powered by GitBook
On this page
  • Basic Structure
  • Optional Attributes
  • Path Parameters
  • Query Parameters
  • Headers
  • Body
  • Multiple Requests

Was this helpful?

  1. Platform
  2. Advanced
  3. Flows
  4. Flow Types

HTTP Request

Learn about writing HTTP requests in Laminar Editor

Basic Structure

In Laminar, to codify an HTTP request, you must update your flow program to return an object with the following format:

{
  "lam.httpRequest": {
    "method": "POST", // (or "GET", "PUT", "DELETE")
    "url": "https://api.example.com/endpoint",
    "pathParams": { /* optional */ },
    "queryParams": { /* optional */ },
    "headers": { /* optional */ },
    "body": { /* optional */ }
  }
}

Examples

  1. Let's start with a basic GET request to fetch users:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users"
    }
  }
}
  1. Now, let's create a user with a POST request:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "POST",
      "url": "https://api.example.com/products",
      "body": {
        "name": "John Doe",
        "email": "john@example.com"
      }
    }
  }
}

Optional Attributes

Now let's explore each optional attribute and how to use them effectively.

Path Parameters

Path parameters are used to replace dynamic segments in your URL path.

Example:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users/{userId}",
      "pathParams": {
        "userId": "12345"
      }
    }
  }
}

This will resolve to a request to https://api.example.com/users/12345.

Query Parameters

Query parameters add a query string to your URL.

Example:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users",
      "queryParams": {
        "page": 1,
        "limit": 10,
        "sort": "name"
      }
    }
  }
}

This will resolve to a request to https://api.example.com/users?page=1&limit=10&sort=name

Headers

Headers allow you to send additional information with your request.

Example:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users",
      "headers": {
        "Authorization": "Bearer token123",
        "Content-Type": "application/json",
        "Accept-Language": "en-US"
      }
    }
  }
}

Body

The body contains data sent with the request. It's typically used with POST, PUT, and PATCH methods.

Example:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "POST",
      "url": "https://api.example.com/users",
      "headers": {
        "Content-Type": "application/json"
      },
      "body": {
        "name": "Jane Smith",
        "email": "jane@example.com",
        "role": "admin"
      }
    }
  }
}

Multiple Requests

You can make your batch requests more powerful by using dynamic path parameters. This is especially useful when working with lists of IDs:

(payload) => {
  const { input } = payload;
  
  return userIds.map(userId => ({
  "lam.httpRequest": {
    "method": "GET",
    "url": "https://api.example.com/users/{userId}",
    "pathParams": {
      "userId": userId
    }
  }
}));

PreviousFlow TypesNextData Transformations

Last updated 2 months ago

Was this helpful?

Laminar also supports sending multiple HTTP requests in a single operation. This is useful for batch processing or when you need to perform several related actions at once. See .

HTTP Request Batching