So far, we have cooked the things required for writing code for our REST web client; in this section, we will be writing actual code:
- Add a simple code to call or consume your product APIs.
If you created a new project in the same solution (refer to step 1 of the section Cooking the web client), please make sure that the project Product API is running before you start your web client project.
- Add a new class (Ctrl + Shift + C) in the Client folder and name it RestSharpWebClient.
- Now open the RestSharpWebClient class and add the following code:
private readonly RestClient _client = new RestClient("http://localhost:10065/api/"); ...