The HTTP Request block

View as Markdown

The HTTP Request block runs an HTTP request that you select from a collection. It sends the response and any test results from one of its output ports.

The HTTP Request block consumes one credit each time it runs. To learn more, see How Flows consume credits.

Input

Send - If you connect another block to this input port, that block triggers the HTTP Request block to run. This connection is optional. The HTTP Request block will run when the flow runs, even if this port isn’t connected to another block.

Variables - If the selected request obtains values from variables, those variables will be listed here. Requests can use variables to set values for query parameters and for elements of the request body.

When a request is created in a collection, if a query parameter’s value was set without using a variable:

  • No variable will be listed for it in the HTTP Request block.

  • There is no way to override its value from a flow.

To learn how to set or override these variable values, see Setup.

Outputs

Success - Sends the response of a successful API request and any passed or failed test results. To succeed, a request must return a 2xx HTTP status code.

Fail - Sends the response of an unsuccessful API request and any passed or failed test results. A request will fail if it returns an HTTP status code other than 2xx.

Setup

Find or create new request - Click to open a dropdown list showing all the collections in your workspace. Select a collection, then select a request or Create a new request. If there are no collections in the workspace, some introductory requests will appear that you can choose from to get started.

Variables - To assign a value to a request’s variable, use either of the following methods:

  • Connect another block’s output port to the variable’s input port.

  • Click Add icon Add data blocks to Insert a data block inline.

You can also use these methods to assign values to environment variables or dynamic variables used in a request. If your request uses dynamic variables, the dynamic variables will work as usual in your flow. If you want to override their values, use one of the value assignment methods to assign the values you prefer.

Additional Settings

Parse Response - Specify how the HTTP Request block parses the response it sends. Select from the following options:

  • Auto
  • JSON
  • XML
  • HTML
  • Text

Allow scripts to update environment variables - Requests can change environment variables’ values with scripts. When this toggle is on (default), if pre-request or post-response scripts change an environment variable’s value, the new value persists after the HTTP Request block completes its task. Turn this toggle off to prevent those changes from persisting after each time the block completes its task.

Ignore test failures when routing - When this toggle is on (default), the HTTP Request block routes any response with a 2xx code through the Success output port even if it includes failed tests. Turn off the toggle to route responses through the Fail output port if any tests fail.

Create a new request

To create new and edit existing requests, you can use the Postman Flows request editor that’s built into the HTTP Request block. To create a request in the HTTP Request block, do the following:

  1. Click Find or create new request to open a dropdown list showing the collections in your workspace.

  2. Select a collection and click Create a new request. If you don’t have any collections, click Create a new request. The Postman Flows request editor opens.

    Postman Flows request editor
  3. In the request editor, select a method from the dropdown list and enter a URL. Alternatively, you can copy a cURL command from your terminal and paste it here. Besides the URL, this add the parameters, headers, and body specified in your cURL command.

  4. (Optional) Select and edit the request’s name.

  5. (Optional) Select and edit the request’s parameters, headers, and body.

  6. Click Save.

Update environment variables with scripts

Requests can change environment variables’ values with scripts. You can configure the HTTP Request block so that environment variable values changed by pre-request and post-request scripts persist or reset when the block’s run completes. By default, script-changed values persist in new HTTP Request blocks. Deployed flows don’t support persistent changed values for environment variables.

To turn persistent changes to environment variables on or off, do the following:

  1. Click the HTTP Request block.

  2. Click Setting icon Additional Settings.

  3. Next to Allow persistent changes to environment values, turn the toggle on or off. Delete icon Left is off, Delete icon right is on.

  4. Select a format from the dropdown list.

Example

To see the HTTP Request block in an example flow, check out Flow Snippets: HTTP Request.

The Select and Evaluate blocks are often connected to the HTTP Request block. The Select block is useful for extracting specific information from a response. The Evaluate block is useful for transforming response data and creating conditions to route data in your flow based on a response.

For tutorials that use the HTTP Request block, see the following: