Sending Json with c# and WebSocket4Net -


i attempting send following json data server via websockets in c#:

    {                  "method": "ms.remote.control",         "params": {             "cmd": "click",             "dataofcmd": key,             "option": "false",             "typeofremote": "sendremotekey"         }     } 

i using following code send data server:

string json = @"{""method"":""ms.remote.control"",""params"":""{""cmd"":""click"",""dataofcmd"":""key_menu"",""option"":""false"",""typeofremote"":""sendremotekey""}""}";  string message = jsonconvert.serializeobject(json);  websocketclient.send(message); 

this output of json data after serialization:

"{\"method\":\"ms.remote.control\",\"params\":\"{\"cmd\":\"click\",\"dataofcmd\":\"key_menu\",\"option\":\"false\",\"typeofremote\":\"sendremotekey\"}\"}" 

i'm getting following response server:

message received. server answered:

{"event":"ms.error","data":{"message":"missing method field message"}} 

am formatting json incorrectly? know json data correct message works fine python program attempting port from.

i figured out. server required json formatted above. formatted json follows , command successful!

 string json = @" {             ""method"": ""ms.remote.control"",             ""params"": {                              ""cmd"": ""click"",                 ""dataofcmd"": ""key_volup"",                 ""option"": ""false"",                 ""typeofremote"": ""sendremotekey""             }                     }"; 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -