Adding the correct parameters to REST Request using RestSharp in C# -


i trying generate correct parameters using restsharp somehow either internal server error (500) or not acceptable (406) when making request. have made request using google chrome extension postman when using raw json format. looking way convert raw json format use restsharp service in c#. here raw json works.

{   "clitemplatecommand" : {     "targetdevices" : {       "targetdevice" : {         "targetdeviceid" : "123",         "variablevalues" : {           "variablevalue" : {             "name" : "interface",             "value" : "gigabitethernet101/1/0/22"           }         }       }     },     "templatename" : "studentconfig"   } } 

is there can me convert can feed request using restsharp. here code snippet using try accomplish this:

request.requestformat = dataformat.json;             request.addheader("authorization", "basic " + encodedpass);             request.addheader("content-type", "application/json");             string json =                 "{‘clitemplatecommand’ : { ‘targetdevices’ : ‘targetdevice’ : " +                 "{ ‘targetdeviceid’ : ‘123’, ‘variablevalues’ : { ‘variablevalue’ :  ‘name’ : ‘interface’, ‘value’ " +                 ": ‘gigabitethernet101/1/0/22’ } } } }, ‘templatename’ : ‘studentconfig’ }}";             request.addparameter("application/json", json, parametertype.requestbody);             irestresponse response = restclient.execute(request); 


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -