Search code examples
jsonpostcontent-typex-www-form-urlencoded

What are the differences between application/json and application/x-www-form-urlencoded?


What is the difference between

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

and

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


Solution

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

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

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

    Name=John+Smith&Age=23