0%

Four body format for POST (form-data, x-www-form-urlencoded, raw, binary)

Four body format for POST

format-data

multipart/form-data, it can upload multiple key-values and files.

multipart/form-data

1
2
3
4
5
6
7
8
9
10
11
12
13
// axios simple sample
let formData = new FormData();
formData.append("username", "username");
formData.append("password", "password");

axios({
method: "post",
url: "xxx",
data: formData,
headers: {
"Content-Type": "multipart/form-data",
},
})

x-www-form-urlencoded

application/x-www-from-urlencoded, it converts data to key-values and cannot upload files.

application/x-www-from-urlencoded

raw

It can upload text in any format. We always upload JSON data in this way.

content-type Note
text/plain Text
application/javascript JavaScript
application/json JSON
text/html HTML
application/xml XML

raw

binary

application/octet-stream, only binary data can be upload, usually used to upload files. Because it is not key-value format, only one data can be passed at once.

binary

-------------The end of this article, thanks for reading-------------