Table of Contents

Class RestInvoker

Namespace
Geotab.Checkmate.Web
Assembly
Geotab.Checkmate.ObjectModel.dll

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 int

The 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

url string

The URL.

method string

The supported HTTP method.

payload object

The payload.

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 string
method string
payload object
cancellationToken CancellationToken

Returns

Task<Dictionary<string, 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.