Quantcast
Channel: Json.NET
Viewing all articles
Browse latest Browse all 1767

Closed Issue: How to create param object in JArray using json.net dll [24096]

$
0
0
I have to send a request as follows in .Net-
{"method" : "exec","params" : [{"url" : "sys/login/user","data" : [{"user" : "abc","passwd" : "pqr"}]}],"id" : 1}

I am not able to create the JArray object for params for the above command.
I tried the following -
JObject joe = new JObject();
joe.Add(new JProperty("method", "exec"));
joe.Add(new JProperty("params", @"[{""url"" : ""sys/login/user"",""data"" : [{""user"" : ""abc"",""passwd"" : ""pqr""}]}]"));
joe.Add(new JProperty("id", "1"));

string s = JsonConvert.SerializeObject(joe);
byte[] byteArray = Encoding.UTF8.GetBytes(s);
webRequest.ContentLength = byteArray.Length;
Stream dataStream = webRequest.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse webResponse = webRequest.GetResponse();

But getting error in webRequest.GetResponse(); as
"The underlying connection was closed: An unexpected error occurred on a receive."

Please guide me on the same.
Thanks

Viewing all articles
Browse latest Browse all 1767


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>