Interface IHttpApi
Namespace: Casewhere.Runtime.DSL.Api
Assembly: Casewhere.Runtime.dll
Support some methods to allow to make the HTTP request to the external service
public interface IHttpApi : IDslApi
Implements
Extension Methods
ObjectExtension.ConvertToBsonValue(object), EnumExtensions.DeepClone<IHttpApi>(IHttpApi)
Methods
Get<TData, TError>(HttpApiGetRequest)
Make a GET request and return the data or error of the request
HttpApiResponse<TData, TError> Get<TData, TError>(HttpApiGetRequest httpApiGetRequest)
Parameters
httpApiGetRequest
HttpApiGetRequest
A GET request
Returns
HttpApiResponse<TData, TError>
Return a HttpApiResponse
Type Parameters
TData
The data type
TError
The error type
Examples
var httpApi = @apiFactory.Get<IHttpApi>();
var url = "https://login-demo.casewhere.com/admin/api/rest/v2/sharedconfigurablesettings";
var urlParameters = new Dictionary<string, string>();
urlParameters.Add("sortOrder", "Ascending");
var additionalHeaders = new Dictionary<string, string>();
additionalHeaders.Add("Authorization", "eyJhbGciOiJSUzI1NiIsImtpZCI6...");
var httpResponse = httpApi.Get<JObject, string>(HttpApiRequest.CreateGetRequest(url, urlParameters, additionalHeaders));
Log.Info("Response: {@response}", httpResponse);
Get<TData>(HttpApiGetRequest)
Make a GET request and return the data or error of the request
HttpApiResponse<TData, string> Get<TData>(HttpApiGetRequest httpApiGetRequest)
Parameters
httpApiGetRequest
HttpApiGetRequest
A GET request
Returns
HttpApiResponse<TData, string>
Return a HttpApiResponse
Type Parameters
TData
The data type
Examples
var httpApi = @apiFactory.Get<IHttpApi>();
var samlId = "_baed74d5-78b9-4ab5-93fd-f5bb61b10d03";
var url = "https://nemlogin.kk.dk/nemlogin/loggedInService/{samlId}";
var httpResponse = httpApi.Get<bool>(HttpApiRequest.CreateGetRequest(url));
Log.Info("Response: {@response}", httpResponse);
var newSessionStatus = httpResponse.Data;