SoFunction
Updated on 2025-03-02

The difference and description of the parameters and x-www-form-urlencoded pass values ​​in postman

In Postman, there are many ways to pass parameters, includingparamsandx-www-form-urlencoded

These two methods are different in terms of usage scenarios and the way of passing data.

1. Params

ParamsOptions are used to pass query parameters in the URL. These parameters are usually used for GET requests, but can also be used with other HTTP methods.

Features

  • The parameter is appended as a query string at the end of the URL.
  • Suitable for passing non-sensitive data or for operations such as filtering and sorting.

Example

For a GET request:

/api/users?username=johndoe&age=30

In Postman, you can set it like thisParams

  • Key: username
  • Value: johndoe
  • Key: age
  • Value: 30

2. x-www-form-urlencoded

x-www-form-urlencodedUsed to pass data in the body of an HTTP request, often used in POST requests.

This format encodes data into key-value pairs, similar to a query string, but the data is in the body of the request instead of the URL.

Features

  • Data is passed in the body of an HTTP request, not in the URL.
  • Suitable for passing form data, especially in the case of form submission.
  • The data is URL encoded during transmission (for example, encode spaces as+or%20)。

Example

For a POST request, send the following data:

username=johndoe&age=30

In Postman, you can choosex-www-form-urlencodedOptions and set parameters:

  • Key: username
  • Value: johndoe
  • Key: age
  • Value: 30

Example of usage

Suppose we have a user-registered API endpoint and the URL is/api/register, need to be passedusernameandpassword

Using Params

If usingParamsPassing data, the URL of the POST request will become:

/api/register?username=johndoe&password=secret

In Postman:

  • chooseParamsTab.
  • Add parameters:
    • Key: username
    • Value: johndoe
    • Key: password
    • Value: secret

Using x-www-form-urlencoded

If usingx-www-form-urlencodedPassing data, the URL requested by POST is still/api/register, but the data is passed in the request body.
In Postman:

  • chooseBodyTab.
  • choosex-www-form-urlencoded
  • Add parameters:
    • Key: username
    • Value: johndoe
    • Key: password
    • Value: secret

Summarize

  • Params: Used to pass query parameters in URLs, suitable for GET requests and non-sensitive data.
  • x-www-form-urlencoded: Used to pass data in the request body, suitable for POST request and form data.

Which method to choose depends on the specific usage scenario and data type.

The above is personal experience. I hope you can give you a reference and I hope you can support me more.