Class RestInvoker
Makes HTTP calls to a remote service.
public class RestInvoker : IHttpInvoker
- Inheritance
-
RestInvoker
- Implements
- Inherited Members
Constructors
RestInvoker(int)
Initializes a new instance of the RestInvoker class. Initializes a new instance of the class RestInvoker class.
public RestInvoker(int timeout = 300000)
Parameters
timeout
intThe timeout.
Methods
Invoke(string, string, object?)
Invokes the remote HTTP service and returns the response as an object. Note this method is deprecated. Rather use InvokeAsync(string, string, object?, in CancellationToken)
[Obsolete("Use InvokeAsync")]
public Dictionary<string, object>? Invoke(string url, string method = "GET", object? payload = null)
Parameters
Returns
- Dictionary<string, object>
The response object.
Remarks
When performing a GET request, a dictionary of strings will be used to construct the query string. When performing a POST request, the payload object will be JSON serialized and used as the request body.
Exceptions
- NotSupportedException
The method provided: + method + is not recognized. Acceptable values for the method parameter: GET, POST.
InvokeAsync(string, string, object?, in CancellationToken)
public Task<Dictionary<string, object>?> InvokeAsync(string url, string method = "GET", object? payload = null, in CancellationToken cancellationToken = default)
Parameters
url
stringmethod
stringpayload
objectcancellationToken
CancellationToken
Returns
Remarks
When performing a GET request, a dictionary of strings will be used to construct the query string. When performing a POST request, the payload object will be JSON serialized and used as the request body.