You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The most important difference, however, that async methods that are named after HTTP methods return the `Task<T>` instead of `Task<IRestResponse<T>>`. Because it means that you won't get an error response if the request fails, those methods
58
-
throw an exception.
62
+
Both snippets about use the `GetAsync` extension, which is a wrapper about `ExecuteGetAsync`, which, in turn, is a wrapper around `ExecuteAsync`.
63
+
All `ExecuteAsync` overloads and return the `RestResponse` or `RestResponse<T>`.
59
64
60
-
All `ExecuteAsync` overloads, however, behave in the same way as `Execute` and return the `IRestResponse` or `IRestResponse<T>`.
65
+
The most important difference is that async methods that are named after HTTP methods return the `Task<T>` instead of `Task<RestResponse<T>>`. Because it means that you won't get an error response if the request fails, those methods
66
+
throw an exception. For keeping the API consistent, non-generic functions like `GetAsync` or `PostAsync` also throw an exception if the request fails, although they return the `Task<RestResponse>`.
61
67
62
68
Read [here](error-handling.md) about how RestSharp handles exceptions.
63
69
70
+
RestSharp also offers even simpler way to make JSON calls. You can use the `GetJsonAsync` and `PostJsonAsync` extension methods, which will automatically serialize the request body to JSON and deserialize the response to the specified type.
Read [here](usage.md#json-requests) about making JSON calls without preparing a request object.
78
+
64
79
### Content type
65
80
66
81
RestSharp supports sending XML or JSON body as part of the request. To add a body to the request, simply call `AddJsonBody` or `AddXmlBody` method of the `IRestRequest` instance.
0 commit comments