Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between "Request Payload" vs "Form Data" as seen in Chrome dev tools Network tab

People also ask

What's the difference between request payload vs form data?

If an HTTP request has a message body, it is a "Request Payload" "Form Data" is a subset of Request Payload in which the body is encoded as key1=value1&key2=value2. Whenever Google Chrome can distinguish Form Data from a generic Request Payload, it customizes the formatting.

What is meant by request payload?

The payload of an HTTP request or response consists of HTTP protocol information such as headers, a URL, body content, and version and status information.

Is payload the same as request body?

So Yes, they are the same thing. Show activity on this post. So basically the only difference between HTTP message body and HTTP message payload body is encoding (but only if present). So generalizing the term request payload = request body.

What is form data in Chrome?

FormData is the XHR user's best friend, and it's getting an upgrade in Chrome 50. We're adding methods allowing you to inspect your FormData objects or modify them after-the-fact. You can now use get() , delete() , and iteration helpers like entries , keys , and more. (Check out the full list.)


The Request Payload - or to be more precise: payload body of a HTTP Request

  • is the data normally send by a POST or PUT Request. It's the part after the headers and the CRLF of a HTTP Request.

A request with Content-Type: application/json may look like this:

POST /some-path HTTP/1.1
Content-Type: application/json

{ "foo" : "bar", "name" : "John" }

If you submit this per AJAX the browser simply shows you what it is submitting as payload body. That’s all it can do because it has no idea where the data is coming from.

If you submit a HTML-Form with method="POST" and Content-Type: application/x-www-form-urlencoded or Content-Type: multipart/form-data your request may look like this:

POST /some-path HTTP/1.1
Content-Type: application/x-www-form-urlencoded

foo=bar&name=John

In this case the form-data is the request payload. Here the Browser knows more: it knows that bar is the value of the input-field foo of the submitted form. And that’s what it is showing to you.

So, they differ in the Content-Type but not in the way data is submitted. In both cases the data is in the message-body. And Chrome distinguishes how the data is presented to you in the Developer Tools.


In Chrome, request with 'Content-Type:application/json' shows as Request PayedLoad and sends data as json object.

But request with 'Content-Type:application/x-www-form-urlencoded' shows Form Data and sends data as Key:Value Pair, so if you have array of object in one key it flats that key's value:

{ Id: 1, 
name:'john', 
phones:[{title:'home',number:111111,...},
        {title:'office',number:22222,...}]
}

sends

{ Id: 1, 
name:'john', 
phones:[object object]
phones:[object object]
}

tl;dr of lefloh's (excellent) answer:

  • If an HTTP request has a message body, it is a "Request Payload"
  • "Form Data" is a subset of Request Payload in which the body is encoded as key1=value1&key2=value2
  • Whenever Google Chrome can distinguish Form Data from a generic Request Payload, it customizes the formatting