Static Typing
Since version 4.0 RestClient supports full static typing - the most requested feature since RestClient was released. Static typing is 100% backwards compatible - all the dynamic syntax you know and love works exactly as before, just declare your client as dynamic as usual.
To use static typing declare your client as RestClient, IRestClient or var instead of dynamic - and you get full IntelliSense.
The Resource method
The Resource method takes a string representing the resource you want to access, then you end with the HTTP method you want to use, exactly the same as the dynamic syntax.
var client = new RestClient("https://jsonplaceholder.typicode.com");
User user = await client.Resource("users/1").Get();
You can chain Resource calls if you prefer:
var client = new RestClient("https://jsonplaceholder.typicode.com");
User user = await client.Resource("users").Resource("1").Get();
Typed responses
The HTTP methods return dynamic, which supports implicit casting to your static type as shown above. If you prefer to be explicit use the generic overloads:
var client = new RestClient("https://jsonplaceholder.typicode.com");
var user = await client.Resource("users/1").Get<User>();
var users = await client.Resource("users").Get<List<User>>();
The mutable methods take a typed body and can return a typed response too:
var client = new RestClient("https://jsonplaceholder.typicode.com");
User createdUser = await client.Resource("users").Post(new User { Name = "foo" });
// Or explicitly
var createdUser = await client.Resource("users").Post<User, User>(new User { Name = "foo" });
Headers, Query Strings and everything else
Headers, query strings and authorization work with static typing exactly the same as the dynamic syntax:
var client = new RestClient("https://jsonplaceholder.typicode.com");
var users = await client
.Headers(new { CacheControl = "no-cache" })
.Resource("users")
.Query(new { id = 2 })
.Get<List<User>>();
See also Typed Clients for SDK style clients that take an IRestClient, and Passthrough HttpClient for dropping down to the underlying HttpClient.