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

angularjs - Redirect to a new template in angular js -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

Desktop Launcher for Python Script Starts Program in Wrong Path (Linux) -