differences in application/json and application/x-www-form-urlencoded

Prithvi Raj Nandiwal picture Prithvi Raj Nandiwal · Mar 26, 2012 · Viewed 100.3k times · Source

What is the difference between

request.ContentType = "application/json; charset=utf-8";

and

webRequest.ContentType = "application/x-www-form-urlencoded";

Answer

Icarus picture Icarus · Mar 26, 2012

The first case is telling the web server that you are posting JSON data as in:

{ Name : 'John Smith', Age: 23}

The second option is telling the web server that you will be encoding the parameters in the URL as in:

Name=John+Smith&Age=23