Home > OS >  What is the difference between `GetAsync` and `ExecuteGetAsync` in RestSharp?
What is the difference between `GetAsync` and `ExecuteGetAsync` in RestSharp?

Time:07-05

What is the difference between the methods RestClient.GetAsync and RestClient.ExecuteGetAsync? When should I use one or the other?

Thank you in advance.

CodePudding user response:

GetAsync will throw an exception if the server returns an error because it is not part of RestClient interface and return Task<int> i.e. there is no way to set and response status code.

while

ExecuteGetAsync will not throw an exception if the server return an error because it's return type is RestResponse and it has ResponseStatus property to set an error.

For more information: https://restsharp.dev/error-handling.html

  • Related