Home Ask Login Register

Developers Planet

Your answer is one click away!

Inane February 2016

How do I use PUT in RestSharp?

I want to use PUT, but I can only find examples of how to use POST. The json data I want to send is sent using this cURL command curl -i -H "Content-Type: application/json" -X PUT -d {"status":1}' Also I want the "1" after status and the last "3" to be variables.


NikolaiDante February 2016

Set the method as you create the rest request:

public void Update(int id, Product product)
  var request = new RestRequest("Products/" + id, Method.PUT);


(Aircode Warning)

  var status = 1;
  var id = 3;
  var request = new RestRequest("/auto/api/v1.0/relays/" + id, Method.PUT);
  request.AddJsonBody(new { status = status });

(Compiling Fiddle)

Post Status

Asked in February 2016
Viewed 2,201 times
Voted 8
Answered 1 times


Leave an answer

Quote of the day: live life