What is the difference between x-www-form-urlencoded and raw data forms in a Postman Chrome app?

I am using the Postman Chrome extension to test the web service. Three options are available for entering data. I assume this is the raw material for sending JSON. What is the difference between the other two, form data and x-www-form-urlencoded?

+160
rest web-services forms postman
Nov 03 '14 at 21:24
source share
4 answers

These are the different types of form content defined by the W3C. If you want to send plain text / ASCII data then x-www-form-urlencoded will work . This is the default.

But if you need to send non-ASCII text or binary large data, form data is for this.

You can use Raw if you want to send plain text or JSON or any other kind of string. As the name suggests, the postman sends your raw string data unchanged. The type of data that you send can be set using the header of the content type from the drop-down list.

Binary data can be used when you want to attach non-text data to a query, for example, a video / audio file, images, or any other binary data file.

Refer to this link for further reading: Forms in HTML documents

+176
Nov 04 '14 at 8:42
source share

This explains better: Postman docs

Request body

When building queries, you often turn to the query body editor. The postman allows you to send almost any HTTP request (if you canโ€™t send something, let us know!). The body editor is divided into 4 areas and has various controls depending on the type of body.

data form

multipart / form-data is the default encoding used by the web form to transmit data. This simulates filling out a form on a website and submitting it. The form data editor allows you to set key / value pairs (using the key value editor) for your data. You can also attach files to the key. Please note that due to limitations in the HTML5 specification, files are not stored in history or collections. You will need to select the file again while sending the request.

urlencoded

This encoding is the same as that used in the URL parameters. You just need to enter key / value pairs, and the postman will correctly encode the keys and values. Please note that you cannot upload files through this encoding mode. There may be some confusion between form data and urlencoded, so check your API first.

raw

A raw request can contain anything. The postman does not touch the line entered in the source editor, except for changing environment variables. Everything that you put in the text area is sent with a request. The raw editor allows you to set the type of formatting along with the correct header, which you must send with the raw body. You can also manually set the Content-Type header. Usually you send XML or JSON data here.

binary

binary data allows you to send things that you cannot enter into Postman. For example, images, audio or video files. You can also send text files. As mentioned earlier in the data section of the form, you will need to re-link the file if you upload the request through a story or collection.

UPDATE

As pointed out by VKK , the WHATWG spec says that urlencoded is the default encoding type for forms.

The invalid default value for these attributes is the application state / x -www-form-urlencoded. An invalid default value for the enctype attribute is also the application / x-www-form-urlencoded state.

+79
Apr 6 '16 at 13:13
source share

multi-part / form data ,

The note. Please refer to RFC2388 for more information on file downloads , including backward compatibility issues, the relationship between "multipart / form-data" and other types of content, performance issues, etc.

Please refer to the application for information on security issues for forms.

The content type "application / x-www-form-urlencoded" is inefficient for sending large amounts of binary data or text containing non-ASCII characters. The content type "multipart / form-data" should be used to submit forms that contain files, non-ASCII data, and binary data.

The content type "multipart / form-data" follows the rules of all composite MIME data streams described in RFC2045 . The definition of "multipart / form-data" is available in the [IANA] registry.

The "multipart / form-data" message contains a series of parts, each of which represents a successful control. Parts are sent to the processing agent in the same order in which the corresponding controls are displayed in the document flow. Part boundaries should not be found in any of the data; how this is done is beyond the scope of this specification.

As with all composite MIME types, each part has an optional "Content-Type" header, which defaults to "text / plain". User agents must provide a "Content-Type" header followed by a "charset" parameter.

application / x-www-form-urlencoded

This is the default content type. Forms submitted with this content type should be encoded as follows:

The names and values โ€‹โ€‹of the controls are escaped. +', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by " +', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by % HH', a percent sign and two hexadecimal digits representing the ASCII character code. Line +', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by represented in the form of "CR LF" pairs (i.e. %0D%0A'). The control names/values are listed in the order they appear in the document. The name is separated from the value by %0D%0A'). The control names/values are listed in the order they appear in the document. The name is separated from the value by %0D%0A'). The control names/values are listed in the order they appear in the document. The name is separated from the value by %0D%0A'). The control names/values are listed in the order they appear in the document. The name is separated from the value by %0D%0A'). The control names/values are listed in the order they appear in the document. The name is separated from the value by = ', and the name / value pairs are separated by the sign' & '.

application/x-www-form-urlencoded that the body of the HTTP message sent to the server, in fact, is one giant query string - name / value pairs are separated by an ampersand (&), and names are separated from values โ€‹โ€‹by an equal sign, an equal sign An example of this can be:

 MyVariableOne=ValueOne&MyVariableTwo=ValueTwo 

The content type "application / x-www-form-urlencoded" is inefficient for sending large amounts of binary data or text containing non-ASCII characters. The content type "multipart / form-data" should be used to submit forms that contain files, non-ASCII data, and binary data.

+16
Nov 15 '17 at 9:36 on
source share

Here are a few additional examples to see the raw text that the Postman sends in the request. You can see this by opening the Postman console:

enter image description here

Data form

heading

 content-type: multipart/form-data; boundary=--------------------------590299136414163472038474 

body

 key1=value1key2=value2 

x-www-form-urlencoded

heading

 Content-Type: application/x-www-form-urlencoded 

body

 key1=value1&key2=value2 

Raw text

heading

 Content-Type: text/plain 

body

 This is some text. 

Raw json

heading

 Content-Type: application/json 

body

 {"key1":"value1","key2":"value2"} 
0
May 04 '19 at 17:17
source share



All Articles