Skip to main content

Overview

Send REST or GraphQL requests inside a test and optionally store the response for later steps (status, headers, body). API Request overview

At a glance

  • Request types: REST or GraphQL (GraphQL uses POST and JSON automatically)
  • Methods: GET, POST, PUT, DELETE, PATCH
  • Inputs: URL, Params, Headers, Body (Raw JSON or Form Data)
  • GraphQL: Query, Variables, optional Operation name
  • Store result: Save to a response variable for later use
  • Expressions: Use environment and expression variables in any field
REST form GraphQL editors

Common actions

  • GET with params
    • Choose REST → Method: GET
    • Enter URL → add Params (key/value)
    • Optional Headers (e.g., Authorization)
    • Set Response variable if you’ll reuse the data
  • POST JSON
    • REST → Method: POST
    • Headers: Content-Type application/json (+ auth if needed)
    • Body: Raw → JSON → paste payload
    • Set Response variable
  • PUT with form data
    • REST → Method: PUT
    • Body: Form Data → add fields
    • Add auth header if required
  • GraphQL query
    • Select GraphQL → URL = endpoint
    • Paste Query and Variables (JSON)
    • Optional Operation name → set Response variable
  • GraphQL mutation
    • Same as query → paste mutation and input variables

Response examples

When you store a response in a variable (e.g., apiResponse), you can access the following properties in subsequent steps:

REST API Response

{
  "status": 200,
  "headers": {
    "content-type": "application/json",
    "x-request-id": "abc-123"
  },
  "body": {
    "id": 42,
    "name": "John Doe",
    "email": "[email protected]"
  }
}
Access response data:
  • Status: ${apiResponse.status}
  • Header: ${apiResponse.headers['content-type']}
  • Body field: ${apiResponse.body.id}
  • Nested field: ${apiResponse.body.user.profile.name}

GraphQL Response

{
  "status": 200,
  "headers": {
    "content-type": "application/json"
  },
  "body": {
    "data": {
      "user": {
        "id": "123",
        "username": "johndoe",
        "posts": [
          {
            "title": "My First Post",
            "likes": 42
          }
        ]
      }
    }
  }
}
Access GraphQL data:
  • User ID: ${apiResponse.body.data.user.id}
  • First post title: ${apiResponse.body.data.user.posts[0].title}
  • Post likes: ${apiResponse.body.data.user.posts[0].likes}

Error Response

{
  "status": 401,
  "headers": {
    "content-type": "application/json"
  },
  "body": {
    "error": "Unauthorized",
    "message": "Invalid API token"
  }
}
Check for errors:
  • Verify status: Use Verify Value step to assert ${apiResponse.status} equals 200
  • Check error message: ${apiResponse.body.message}

Common use cases

Using response data in Fill step:
Fill field with: ${apiResponse.body.token}
Conditional logic based on status:
If ${apiResponse.status} equals 200
  Then continue test
  Else fail with message
Extract array values:
First item: ${apiResponse.body.items[0].name}
Item count: ${apiResponse.body.items.length}

Helpful options

  • URL preview includes Params automatically
  • Content-Type header set based on Body/GraphQL
  • Beautify for JSON and GraphQL
  • Light/dark editor themes

Troubleshooting

  • 401 Unauthorized: Check Authorization header/token and environment variables
  • 400 Bad Request: Validate JSON syntax and required fields
  • Invalid URL: Include protocol (https://) and correct path
  • GraphQL errors: Inspect errors alongside data
  • Missing response variable: Ensure a valid name is set and the step passes

Best practices

  • Use environment variables for base URLs and tokens
  • Request only the fields you need (GraphQL)
  • Prefer variables over string interpolation in GraphQL
  • Validate expected status codes in a follow-up step
  • Never hardcode secrets in tests