Codeunit 18122328 EOS004 REST Client
A general-purpose REST client to simplify making HTTP requests.
procedure BaseUri(newBaseUri: Text)
Sets the base URI of the request to be made.
Text[]
procedure BaseUri(): Text
Gets the base URI of the request to be made.
Text[]
procedure InstanceName(): Text
Returns the name of the REST client. This can be used to identify the client in events.
Returns Text[]
The name of the REST client.
procedure InstanceName(NewValue: Text)
Sets the name of the REST client. This can be used to identify the client in events.
NewValue Text[]
The name of the REST client.
procedure AddQueryParam(Name: Text; Value: Text)
Adds an entry to list of query parameters.
Name Text[]
The name of the query parameter.
Value Text[]
The value of the query parameter.
procedure AddQueryParam(Name: Text; Value: Text; UrlEncode: Boolean)
Adds an entry to list of query parameters.
Name Text[]
The name of the query parameter.
Value Text[]
The value of the query parameter.
UrlEncode Boolean
If True will UrlEncode the values
procedure AddQueryParam(params: Dictionary of [Text, Text])
Adds entries to list of query parameters.
params Dictionary[Text,Text]
The key-value-pairs to be added to the query parameters.
procedure AddQueryParam(params: Dictionary of [Text, Text]; UrlEncode: Boolean)
Adds entries to list of query parameters.
params Dictionary[Text,Text]
The key-value-pairs to be added to the query parameters.
UrlEncode Boolean
If True will UrlEncode the values
procedure GetQueryParam(Name: Text): Text
Returns the value of the given query parameter.
Name Text[]
The name of the query parameter.
Returns Text[]
The value of the parameter. If the parameter does not exist, an empty string is returned.
procedure GetQueryParamKeys(): List of [Text]
Returns a list of all currently configured query parameter names.
Returns List[Text]
The list of query parameter names.
procedure RemoveQueryParam(Name: Text): Boolean
Removes a configured query parameter, if it exists
Name Text[]
The name of the query parameter to be removed.
Returns Boolean
True if the parameter existed. False otherwise.
procedure TimeoutSec(newValue: Integer)
Sets the timeout in seconds for the request.
newValue Integer
The timeout in seconds.
procedure TimeoutSec(): Integer
Gets the timeout in seconds for the request.
Integer
procedure UseServerCertificateValidation(): Boolean
Specifies if server certificate validation should be used.
Returns Boolean
The value.
procedure UseServerCertificateValidation(newValue: Boolean)
Specifies if server certificate validation should be used.
newValue Boolean
The value.
procedure Method(newMethod: Enum "Http Request Type")
Specifies the HTTP verb/method to use for the request.
newMethod Enum "Http Request Type"
The verb/method.
procedure Method(newMethod: Text)
Specifies the HTTP verb/method to use for the request.
newMethod Text[]
The verb/method.
procedure Method(): Enum "Http Request Type"
Returns the HTTP verb/method configured to be used for the request.
Returns Enum "Http Request Type"
The verb/method.
procedure SetCredentials(NewUsername: Text; NewPassword: Text; NewDomain: Text)
Sets the credential to use for the request. This setting alone does not enable authentication. For that you need to also specify the type of authentication to use.
NewUsername Text[]
The username.
NewPassword Text[]
The password.
NewDomain Text[]
The domain name.
procedure ClearCredentials()
Clears any credential that have been configured.
procedure UseBasicAuthentication(newUseBasicAuthentication: Boolean)
Specifies that basic HTTP authentication should be used for the request. This requires credentials to be set.
newUseBasicAuthentication Boolean
Enabled or disabled.
procedure UseBasicAuthentication(): Boolean
Returns if basic HTTP authentication is currently active.
Returns Boolean
True or false.
procedure UseStorageConnectionAuthentication(auth: Interface "Storage Service Authorization"; AccountName: Text)
Enables Azure Storage authentication for this request.
auth Interface "Storage Service Authorization"
The authentication interface.
AccountName Text[]
The Azure storage account to use.
procedure Body(is: InStream)
Sets the body for the request from a stream and sets the content type to be octet-stream
.
is InStream
The input stream.
procedure Body(is: InStream; ContentType: Text)
Sets the body for the request from a stream and a specific content type.
is InStream
The input stream.
ContentType Text[]
The content type to use. If you specify an empty string, no content type is applied to the body.
procedure Body(var TempBlob: Codeunit "Temp Blob"; ContentType: Text)
Sets the body for the request from a BLOB and a specific content type.
TempBlob Codeunit "Temp Blob"
The input BLOB.
ContentType Text[]
The content type to use. If you specify an empty string, no content type is applied to the body.
procedure Body(jo: JsonObject)
Sets the body for the request from a JSON object. This will implicitly set the content type to be application/json
.
jo JsonObject
The JSON object.
procedure Body(ja: JsonArray)
Sets the body for the request from a JSON array. This will implicitly set the content type to be application/json
.
ja JsonArray
The JSON array.
procedure Accepts(): Text
Gets the content type that is expected for the body of the request.
Returns Text[]
The requested content type.
procedure Accepts(NewValue: Text): Text
Sets the content type that is expected for the body of the request.
NewValue Text[]
The content type to be set.
Returns Text[]
procedure ResponseStatus(): Integer
Returns the HTTP status of the last response.
Returns Integer
The HTTP status.
procedure ResponseStatusSuccess(): Boolean
Returns true if the last response was succesful.
Returns Boolean
True of False.
procedure ResponseBody(): Text
Returns the body of the last reposonse as a string.
Returns Text[]
The response as string.
procedure ResponseBodyAsJsonObject(): JsonObject
Returns the body of the last reposonse, converting it to JSON object.
Returns JsonObject
The JSON object.
procedure ResponseBodyAsJsonArray(): JsonArray
Returns the body of the last reposonse, converting it to JSON array.
Returns JsonArray
The JSON array.
procedure ResponseBodyAsXmlDoc(): XmlDocument
Returns the body of the last reposonse, converting it to an XML document.
Returns XmlDocument
The XML document.
procedure ResponseBodyAsStream(Result: InStream)
Returns the body of the last reposonse as a stream.
InStream
procedure ResponseBodyAsTempBlob(var blob: Codeunit "Temp Blob")
Returns the body of the last reposonse as a TempBlob
Codeunit "Temp Blob"
procedure ResponseHeaders(): HttpHeaders
Returns the headers of the last reposonse.
Returns HttpHeaders
The response headers.
procedure RemoveHeader(HeaderKey: Text): Boolean
Removes an item from the request headers, if it exists
HeaderKey Text[]
The name of the header to be removed.
Returns Boolean
true
if the header was removed. false
otherwise.
procedure SetHeader(HeaderKey: Text; HeaderValue: Text)
Sets a request header to be used for the request. The header value added is validated during the request.
HeaderKey Text[]
The header key.
HeaderValue Text[]
The header value.
procedure SetHeader(HeaderKey: Text; HeaderValue: Text; Validate: Boolean)
Sets a request header to be used for the request.
HeaderKey Text[]
The header key.
HeaderValue Text[]
The header value.
Validate Boolean
Specifies if the header value should be validated when sending the request.
procedure SetHeader(HeaderKey: Text; HeaderValue: SecretText; Validate: Boolean)
Sets a request header to be used for the request.
HeaderKey Text[]
The header key.
HeaderValue SecretText
The header value.
Validate Boolean
Specifies if the header value should be validated when sending the request.
procedure SendRequest()
Sends the request. This is a TryFunction.
procedure SendRequest(HttpClient: HttpClient)
Sends the request using the given HTTP client. This is a TryFunction.
HttpClient HttpClient
The HTTP client to use for sending.
procedure SendRequest(Resource: Text)
Sends the request to a given resource. The resource is appended to the base URI. This is a TryFunction.
Resource Text[]
The resource to be appended to the base URI.
procedure SendRequest(Resource: Text; HttpClient: HttpClient)
Sends the request to a given resource using the given HTTP client. The resource is appended to the base URI. This is a TryFunction.
Resource Text[]
The resource to be appended to the base URI.
HttpClient HttpClient
The HTTP client to use for sending.
procedure ThrowIfNotSuccessStatus()
Throws a generic error message if the request was not successful.
procedure ResetResponse()
Resets all response-related properties.
procedure SetServiceConfig(NewServiceConfig: Record "EOS004 Service Config.")
Record "EOS004 Service Config."
procedure SetServiceConfig(NewServiceConfigCode: Code[20])
Code[20]
local procedure OnAfterConfigureClient(HttpClient: HttpClient)
Event that is raised after the HTTP client has been configured.
This can be used to add custom configuration to the HTTP client.
Use the Name
property to identify the client in the event handler.
HttpClient HttpClient
The HTTP client that has been configured.
local procedure OnBeforeSendRequest(Request: HttpRequestMessage)
Event that is raised before the request is sent.
Use the Name
property to identify the client in the event handler.
Request HttpRequestMessage
The HTTP request about to be sent.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.