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
{"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