httpGet
Runs an HTTP Get request and returns the HTTP response from the server.
The content type provided in the request's header is set by default to application/json. Use this function when the endpoint expects a JSON object parameter.
This is suitable for all modules of business service components.
Syntax
function httpGet(url : string, obj : any, getOptions : IFtosHttpGetOptions): IFtosHttpResult
| Parameter | Type | Description |
|---|---|---|
url
|
string | The service endpoint's URI. For instance, the address of a REST API endpoint. |
obj optional |
any | Key-value pairs in JSON format to be passed in the request's body. |
getOptions optional |
IFtosHttpGetOptions | Additional options to be passed to the HTTP request. |
Type Aliases
Allows you to define the HTTP request's additional options.
{
additionalHeaders? : any;
clientCertificate? : WorkflowClientCertificate;
httpVerb? : string;
multipartArguments? : IFtosHttpPostMultiPartArgument[];
responseType? : "Default" | "String" | "JSON" | "ByteArray";
timeout? : number;
}
| Property | Type | Description |
|---|---|---|
additionalHeaders (optional) |
any | Key-value pairs in JSON format to be passed as the request's custom headers. |
clientCertificate(optional)
|
WorkflowClientCertificate | Registered client certificate required for client authentication via TLS/SSL. For information on how to register client certificates, see the Platform documentation. For information on how to retrieve a registered client certificate, see ftos.utils.getCertificate. |
httpVerb (optional) |
string | Allows you to use an HTTP request method different from GET, such as POST, DELETE, etc. |
multipartArguments (optional) |
IFtosHttpPostMultiPartArgument[] | Allows you to define settings for HTTP range requests when sending multpart documents over the network. |
responseType (optional) |
"Default" | "String" | "JSON" | "ByteArray" | The format in which the HTTP response will be returned:
|
timeout (optional) |
number | Maximum number of seconds to wait for the HTTP response. |
Allows you to define settings for HTTP range requests when sending multpart documents over the network.
{
bytes : number[];
contentType : string;
fileName : string;
name : string;
}
| Property | Type | Description |
|---|---|---|
bytes
|
number[] | Indicates the range of bytes retrieved from the server. |
contentType
|
string | Value of the Content-Type header of the HTTP request. |
fileName
|
string | Name of the file transmitted. |
name
|
string | Name of the HTML field transmitted. |
Return Value
Returns the HTTP response of the HTTP Get request. For example:
{
"IsSuccess": true,
"Response": {
"access_token": "36db7a81-15ca-4957-9607-bbf446e6c3a9",
"expires_in": 1200.0,
"email": "host@change.me",
"error": null
},
"StatusCode": 200
}
If the response is returned in JSON format, the following properties are supported by the return value, corresponding to its first level keys: .IsSuccess, .Response, and .StatusCode.
The
Response key in the result is a JSON object, not a string as when using the callGetMethod function.Examples
In this example:
- We issue a Get API request to the https://www.fintechos.com/Studio/api/authorize/GetToken endpoint.
- We provide the id, username, password, and response_type parameters in the request's URL.
- We extract the access_token from the request's Response.
- We save the result in a variable called token.
var token = httpGet('https://www.fintechos.com/Studio/api/authorize/GetToken?client_id=123&username=user&password=pass&response_type=token').Response['access_token'];