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
Post a Comment