x-www-form-urlencoded
vs form-data

kiran
Jan 19, 2022

Recently I was integrating an email api, and I was able to find the sample snippets in curl and other languages as well.That’s cool!

But the API reference page did not mention the Content Type that their api’s accept.What do you accept ?

application/json
application/x-www-form-urlencoded
multipart/form-data

Ofcourse the curl snippets that they provided use -F flag which signifies multipart/form-data.
And -d in curl signifies application/x-www-form-urlencoded.

When sending files, you use multipart/form-data.
Does that mean we cannot use application/x-www-form-urlencoded to send files to an api ? You can as per this but its inefficient and not the preferred way.

I did not look into the http spec as such.

--

--

kiran

I am a software engineer by profession. I write so as to remind my selves when I forget :-)