I am using post method in that method i want to pass entire Json in string like this way
{Data:” JsonArray”} in Jssonarray I want to pass this value
{ "version" : 2,
"query" : "Companies, CA",
"begin" : 1,
"end" : 3,
"totalResults" : 718,
"pageNumber" : 0,
"results" : [
{ "company" : "ABC Company Inc.", "city" : "Sacramento", "state" : "CA" } ,
{ "company" : "XYZ Company Inc.", "city" : "San Francisco", "state" : "CA" } ,
{ "company" : "KLM Company Inc.", "city" : "Los Angeles", "state" : "CA" }
]
}
When i pass this I am getting 500 internal Error
Please help me how to pass Entire Json in a single string.
One way is to navigate to http://json2csharp.com/, paste your Json and hit “GO”.
The result will be this one (I fixed the capitalization):
Paste this into your application.
Your POST-Method then could look like this:
And you’re done with this method.
Another method is to use the new JsonValue and JsonArray introduced with Web API whereas you don’t need RootObject and Result.
Just use your POST-Method:
You should get a clue…
You can prettify the whole thing: