• notice
  • Congratulations on the launch of the Sought Tech site

The difference between form-data, x-www-form-urlencoded, and raw in Postman

I. Overview

Postman provides several ways to interact with API or server requests with different types of body parameters. These represent different ways of sending data to the API over HTTP requests.

In this tutorial, we'll explore the difference between using , and in the request body.form-datax-www-form-urlencodedraw

2. form-data

Form-data represents data sent from a website form to an API as part of multipart/form-dataThe option in Postman simulates filling out a form on a website and submitting it. We can edit the form data and let him set different key/value pairs by transforming the key-value editor in the data.form-data

This can also be used to attach a file to a key. However, it should be noted that using HTML5 restricts the file from being in any history or collection. Therefore, we must select the file again when sending the request body. In addition, Postman does not support uploading multiple files and their content types.

Note that Postman will reserve the file path for subsequent use, that is, when we repeatedly make API calls to send the same file to the server. This helps you run a collection with multiple requests for file uploads.

Let's see what it looks like to use it in Postman:form-data

difference-between-form-data-x-www-form-urlencoded-and-raw-in-postman.png

3. x-www-form-urlencoded

URL-encoded data sends the encoded data to the server and uses the same encoding as the URL parameter. To use it, we need to select tabs in their request body. We need to enter key-value pairs to send the request body to the server, and Postman encodes the required data before sending. Postman encodes keys and values.x-www-form-urlencoded

Note that it cannot be used to encode files, so we need to do it manually ourselves. However, it can only encode request body data or URL parameters.

This is also known as the default content type. All forms submitted with this content type follow this encoding pattern:

  • Control names and values are escaped — all space characters are replaced by the "+" sign, and reserved characters follow the RFC 17.38 symbol.

  • The equal sign, i.e. "=", is used to separate the key and value, and the key/value pair is separated by "&".

Let's take a look at the option card in Postman:x-www-form-urlencoded

difference-between-form-data-x-www-form-urlencoded-and-raw-in-postman-1.png

4. raw

As the name suggests, data can contain anything. Postman does not touch the raw string or make any type of change to it. Strings added to the editor are not modified except for substitutions for defined environment variables. This editor allows us to set the different format styles supported by Postman and the correct headings that need to be sent with the raw body. The following types are supported:rawraw

  • text

  • Javascript

  • JSON

  • HTML

  • XML

We can also manually set these Content-Types into our request body:

difference-between-form-data-x-www-form-urlencoded-and-raw-in-postman-2.png

5. The difference between , andform-datax-www-form-urlencodedraw

We can use different forms of data content types as defined by the W3C Committee. They define multiple formats for sending data through the network layer. These include , x-www-form- and data. By default, we can send data in simple text/ASCII format using the x-www-form-urlencoded format. form-dataurlencodedraw

However, there are data limits on using data types. Therefore, we can use form-data to send large binary or non-ASCII text to the server. x-www-form-urlencoded

As the name implies, the data type sends any plain text or JSON to the server. It supports multiple content types, and Compared to other data types, Postman will send raw data without any modifications.raw

We can use data types to send any type of data in the request body. This also includes sending Javascript functions that can be executed on the server side. We can send scripts under the Javascript option. Data types also support markup languages such as HTML and XML. This is helpful when there is no logic on the front end and we need to use the entire HTML/XML page.rawraw

Sixth, the conclusion

In this article, we see some of the request body data types supported by Postman.

We also outline the differences between , , and in Postman. However, we only learned the basics of requests. You browse the Postman online documentation to gain a deeper understanding of these request body types.form-datax-www-form-urlencodedraw


Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+