Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between form data and request payload? [duplicate]

When I send an AJAX Post request and send parameters in queryString in send() method,

Chrome Developer Tool's XHR capture tool shows the parameters under request payload. and when I use jquery's post function, The tool shows parameters under Form Data section.

What is the difference ?

like image 999
Amogh Talpallikar Avatar asked May 08 '12 07:05

Amogh Talpallikar


People also ask

What is a request payload?

A request payload is data that clients send to the server in the body of an HTTP POST, PUT, or PATCH message that contains important information about the request.

What is the difference between form-data and raw in Postman?

Therefore, we can use form-data for sending large binary or non-ASCII text to the server. The raw data type sends any plain text or JSON to the server, as the name suggests. It supports multiple content types, and Postman will send the raw data without any modifications compared to the other data types.

What is difference between payload and message?

In computing and telecommunications, the payload is the part of transmitted data that is the actual intended message. Headers and metadata are sent only to enable payload delivery. In the context of a computer virus or worm, the payload is the portion of the malware which performs malicious action.

What is request payload in REST API?

The Payload of an API Module is the body of your request and response message. It contains the data that you send to the server when you make an API request.


1 Answers

you have not provided enough information how you use the send function, but I assume that you do not set mime type to specify you are sending form data

xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 

the data sent are in this case encoded as you encode a query string

xhr.send("name=foo&value=bar"); 

otherwise it will not be interpreted as form data by Developer Tools.

jquery does majority of work for you in this regard.

Update: To answer explicitly what is the difference...

  • if a request (typically POST) has Content-type header set to application/x-www-form-urlencoded the body is expected to be in the form of a standard querystring with url-encoded key=value pairs joined by &. Form data section then shows the key-value parameters (when viewed parsed). This way was much more common in past because it is a default for HTML forms.

  • other cases are shown in Request payload section (and nowadays parsed for readability as well for common formats like JSON).

like image 89
jJ' Avatar answered Sep 22 '22 06:09

jJ'