How to Access Resources
The URL builder works by simply chaining members that would make up the resource you want to access - ending with the HTTP method you want to use.
This page covers the dynamic syntax. Since version 4.0 you can also use static typing - see Static Typing.
Accessing a resource by identity
Accessing a resource by identity works as you would expect for example if your wanted to perform a GET on https://jsonplaceholder.typicode.com/users/1 you would do the following:
dynamic client = new RestClient("https://jsonplaceholder.typicode.com");
await client.Users(1).Get();
If the resource is annoyingly case sensitive for example if the API responded to only /users not /Users your call would be await client.users(1).Get();
For GET, HEAD, DELETE you can also pass the resource identity in the method, for example if your wanted to perform a DELETE on https://jsonplaceholder.typicode.com/users/1:
dynamic client = new RestClient("https://jsonplaceholder.typicode.com");
await client.Users.Delete(1);
The resource identity can be any primitive type
Nested resources
Nested resources again work as you would expect for example if your wanted to perform a GET on https://jsonplaceholder.typicode.com/users/2/comments you would do the following:
dynamic client = new RestClient("https://jsonplaceholder.typicode.com");
await client.Users(2).Comments.Get()
Awkward resources
You will come across an API that has a resource that isn’t valid C# syntax. To escape invalid C# syntax in a resource use the Resource method for example:
dynamic client = new RestClient("https://jsonplaceholder.typicode.com");
await client.Users(2).Resource("awkward-resource-with-dashes").Get()
When using static typing the Resource method is the primary way to access resources - see Static Typing.
Vanity API - Formatting the Resource URL
If the way you want to write the call in C# and the URL the server expects are in conflict (a case sensitive API is the classic example) a handler can rewrite the URL before it’s sent - see Rewriting the request URL.