How To Post JSON Data With WebRequest In .NET
Hello,
There was a question on how to post a JSON data using the WebRequest class on both C# and VB.NET given that using Ajax, the post data would look like this.
In .NET, you need to store the JSON data into a string object and escape those double quotes before passing it to the WebRequest object.
C#.NET
VB.NET
Cheers! :-)
There was a question on how to post a JSON data using the WebRequest class on both C# and VB.NET given that using Ajax, the post data would look like this.
data: '{ "age": "78", "weight": "51" }'
C#.NET
string postData = "{ \"age\": \"78\", \"weight\": \"51\" }";
Dim postData As String = "{ ""age"": ""78"", ""weight"": ""51"" }"
Cheers! :-)
Comments
Post a Comment