Put, Post, Patch

Put, Post and Patch perform a HTTP action on a resource, they take an optional object as a parameter (can be a anonymous type or a static object type) representing the data you want to submit.

Example usage:

dynamic client = new RestClient("https://jsonplaceholder.typicode.com");

var user = new {  name="foo", email="foo@bar.com", userId=10 }; 

//POST { "name":"foo", "email":"foo@bar.com", "userId":10 } https://jsonplaceholder.typicode.com/users
var result = await client.Users.Post(user);
dynamic client = new RestClient("https://jsonplaceholder.typicode.com");

var user = new User { Name="foo", Email="foo@bar.com" };

//PUT { "name":"foo", "email":"foo@bar.com" }  https://jsonplaceholder.typicode.com/users/1
var result = await client.Users(1).Put(user);
dynamic client = new RestClient("https://jsonplaceholder.typicode.com");

var user = new User { Name="foo", Email="foo@bar.com" };

//PATCH { "name":"foo", "email":"foo@bar.com" }  https://jsonplaceholder.typicode.com/users/1
var result = await client.Users(1).Patch(user);

Posting a raw string body

If you pass a string to Post, Put or Patch it is sent as a raw string body rather than being serialized to JSON.

var client = new RestClient("https://your-server/api");

var response = await client.Resource("your-api-resource").Post("string that you want to post");

You can find more usage examples in the DalSoft.RestClient.Test.Unit and DalSoft.RestClient.Test.Integration projects.

Updated: