Send parameters and body data with API requests in Postman

The Postman API client enables you to send data along with your HTTP requests. You can add query and path parameters to a request and specify their values. You can also add body data to a request in various formats, including form data, URL-encoded, raw, and binary.

Send request parameters

You can specify path and query parameters for a request using the URL box or the Params tab.

  • Query parameters are appended to the end of the request URL, following ? and listed in key-value pairs, separated by & as follows: ?id=1&type=new
  • Path parameters form part of the request URL, and are referenced using placeholders preceded by : as in the following example: /customer/:id

To specify a query parameter, add it directly to the URL or select the Params tab and enter the name and value. When you enter your query parameters in either the URL or the Params tab, these values will update everywhere they're used in Postman.

Parameters aren't automatically URL-encoded. Right-click selected text, and choose EncodeURIComponent to manually encode a parameter value.

To specify a path parameter, enter the parameter name into the URL box, after a colon, for example :id. When you enter a path parameter, Postman will populate it in the Params tab, where you can also edit it.

You can add descriptions to your parameters and they'll appear for anyone sharing the request (for example in your workspace) or viewing your API documentation.

When you're done entering parameters, select Send to send the request. Learn more about creating and sending requests in Postman.

Path parameter

You can use the Bulk Edit option if you prefer to enter your parameters in plain text instead of using the request builder.

Send body data with requests

You need to send body data with requests whenever you want to add or update structured data. For example, if you're sending a request to add a new customer to a database, you might include the customer details in JSON. Typically you use body data with PUT, POST, and PATCH requests.

The Body tab enables you to specify the data you need to send with a request. You can send different types of body data to suit your API.

If you're sending body data, make sure you have the correct headers selected to indicate the content type your API may need to process the received data.

  • For form-data and urlencoded body types, Postman will automatically attach the correct Content-Type header.
  • If you use raw mode for your body data, Postman will set a header based on the type you select (such as text or json).
  • If you manually select a Content-Type header, that value will take precedence over what Postman sets.
  • Postman doesn't set any header type for the binary body type.

By default, Postman will select None for body data. Leave it selected if you don't need to send a body with your request. Otherwise, choose the data type you need for your request body: form data, URL-encoded, raw, binary, or GraphQL.

When you're done entering body data, select Send to send the request. Learn more about creating and sending requests in Postman.

Form data

Website forms often send data to APIs as multipart/form-data. You can replicate this in Postman using the form-data option in the Body tab of your request. Form data enables you to send key-value pairs and specify the content type.

You can also attach a file using form data and send it with your request. Select File in the dropdown list next to a key name, then select the file you want to send. You can select a file from your local system, and Postman saves the file path in the request. The saved file path is relative to your local working directory.

You can also upload a file with test data to your Postman team. This is useful if you want to share the request with others on your team or use the request in a monitor or scheduled collection run. Learn more about uploading files for shared requests and cloud runs.

Add form data

URL-encoded

URL-encoded data uses the same encoding as URL parameters. If your API requires url-encoded data, select x-www-form-urlencoded in the Body tab of your request. Enter your key-value pairs to send with the request and Postman will encode them before sending.

There is sometimes confusion between form data and URL-encoded. If you are unsure which one you need, check with your API provider.

Raw data

You can use raw body data to send anything you can enter as text. In the Body tab of your request, select the raw option and use the dropdown list to indicate the format of your data (Text, JavaScript, JSON, HTML, or XML). Postman will enable syntax-highlighting and appending the relevant headers to your request.

Body JSON

You can set a content type header manually if you need to override the one Postman sends automatically.

You can use variables in your body data and Postman will populate their current values when sending your request.

For JSON raw body data, you can add comments, and they will be stripped out when the request is sent. Single-line comments delimited with // and multi-line comments delimited with /* */ will be removed in the request.

To beautify your XML or JSON, select the text in the editor and then select ⌘+Option+B or Ctrl+Alt+B.

Binary data

You can use binary data to send information you can't enter manually in the Postman editor with your request body, such as image, audio, and video files. (You can also send text files.)

In the Body tab of your request, select the binary option, then select the file you want to send with the request. You can select a file from your local system, and Postman saves the file path in the request. The saved file path is relative to your local working directory.

You can also upload a file with test data to your Postman team. This is useful if you want to share the request with others on your team or use the request in a monitor or scheduled collection run. Learn more about uploading files for shared requests and cloud runs.

Add binary data

GraphQL

You can send GraphQL queries with your Postman requests by selecting the GraphQL option in the Body tab of your request. Enter your code in the Query pane and any variables in the GraphQL Variables pane.

Check out GraphQL in Postman for more information on GraphQL, including how to enable Autocomplete powered by Postman API schemas.

Last modified: 2024/02/05