Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

Thank you in advance.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading