Codeunit 18122328 EOS004 REST Client
Codeunit 18122328 EOS004 REST Client
A general-purpose REST client to simplify making HTTP requests.
Methods
BaseUri
procedure BaseUri(newBaseUri: Text)
Sets the base URI of the request to be made.
Parameters / Return Value
- newBaseUri
Text[]
BaseUri
procedure BaseUri(): Text
Gets the base URI of the request to be made.
Parameters / Return Value
- Returns
Text[]
InstanceName
procedure InstanceName(): Text
Returns the name of the REST client. This can be used to identify the client in events.
Parameters / Return Value
Returns
Text[]The name of the REST client.
InstanceName
procedure InstanceName(NewValue: Text)
Sets the name of the REST client. This can be used to identify the client in events.
Parameters / Return Value
NewValue
Text[]The name of the REST client.
AddQueryParam
procedure AddQueryParam(Name: Text; Value: Text)
Adds an entry to list of query parameters.
Parameters / Return Value
Name
Text[]The name of the query parameter.
Value
Text[]The value of the query parameter.
AddQueryParam
procedure AddQueryParam(Name: Text; Value: Text; UrlEncode: Boolean)
Adds an entry to list of query parameters.
Parameters / Return Value
Name
Text[]The name of the query parameter.
Value
Text[]The value of the query parameter.
UrlEncode
BooleanIf True will UrlEncode the values
AddQueryParam
procedure AddQueryParam(params: Dictionary of [Text, Text])
Adds entries to list of query parameters.
Parameters / Return Value
params
Dictionary[Text,Text]The key-value-pairs to be added to the query parameters.
AddQueryParam
procedure AddQueryParam(params: Dictionary of [Text, Text]; UrlEncode: Boolean)
Adds entries to list of query parameters.
Parameters / Return Value
params
Dictionary[Text,Text]The key-value-pairs to be added to the query parameters.
UrlEncode
BooleanIf True will UrlEncode the values
GetQueryParam
procedure GetQueryParam(Name: Text): Text
Returns the value of the given query parameter.
Parameters / Return Value
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.
GetQueryParamKeys
procedure GetQueryParamKeys(): List of [Text]
Returns a list of all currently configured query parameter names.
Parameters / Return Value
Returns
List[Text]The list of query parameter names.
RemoveQueryParam
procedure RemoveQueryParam(Name: Text): Boolean
Removes a configured query parameter, if it exists
Parameters / Return Value
Name
Text[]The name of the query parameter to be removed.
Returns
BooleanTrue if the parameter existed. False otherwise.
TimeoutSec
procedure TimeoutSec(newValue: Integer)
Sets the timeout in seconds for the request.
Parameters / Return Value
newValue
IntegerThe timeout in seconds.
TimeoutSec
procedure TimeoutSec(): Integer
Gets the timeout in seconds for the request.
Parameters / Return Value
- Returns
Integer
UseServerCertificateValidation
procedure UseServerCertificateValidation(): Boolean
Specifies if server certificate validation should be used.
Parameters / Return Value
Returns
BooleanThe value.
UseServerCertificateValidation
procedure UseServerCertificateValidation(newValue: Boolean)
Specifies if server certificate validation should be used.
Parameters / Return Value
newValue
BooleanThe value.
Method
procedure Method(newMethod: Enum "Http Request Type")
Specifies the HTTP verb/method to use for the request.
Parameters / Return Value
newMethod
Enum "Http Request Type"The verb/method.
Method
procedure Method(newMethod: Text)
Specifies the HTTP verb/method to use for the request.
Parameters / Return Value
newMethod
Text[]The verb/method.
Method
procedure Method(): Enum "Http Request Type"
Returns the HTTP verb/method configured to be used for the request.
Parameters / Return Value
Returns
Enum "Http Request Type"The verb/method.
SetCredentials
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.
Parameters / Return Value
NewUsername
Text[]The username.
NewPassword
Text[]The password.
NewDomain
Text[]The domain name.
ClearCredentials
procedure ClearCredentials()
Clears any credential that have been configured.
UseBasicAuthentication
procedure UseBasicAuthentication(newUseBasicAuthentication: Boolean)
Specifies that basic HTTP authentication should be used for the request. This requires credentials to be set.
Parameters / Return Value
newUseBasicAuthentication
BooleanEnabled or disabled.
UseBasicAuthentication
procedure UseBasicAuthentication(): Boolean
Returns if basic HTTP authentication is currently active.
Parameters / Return Value
Returns
BooleanTrue or false.
UseStorageConnectionAuthentication
procedure UseStorageConnectionAuthentication(auth: Interface "Storage Service Authorization"; AccountName: Text)
Enables Azure Storage authentication for this request.
Parameters / Return Value
auth
Interface "Storage Service Authorization"The authentication interface.
AccountName
Text[]The Azure storage account to use.
Body
procedure Body(is: InStream)
Sets the body for the request from a stream and sets the content type to be octet-stream.
Parameters / Return Value
is
InStreamThe input stream.
Body
procedure Body(is: InStream; ContentType: Text)
Sets the body for the request from a stream and a specific content type.
Parameters / Return Value
is
InStreamThe input stream.
ContentType
Text[]The content type to use. If you specify an empty string, no content type is applied to the body.
Body
procedure Body(var TempBlob: Codeunit "Temp Blob"; ContentType: Text)
Sets the body for the request from a BLOB and a specific content type.
Parameters / Return Value
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.
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.
Parameters / Return Value
jo
JsonObjectThe JSON object.
Body
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.
Parameters / Return Value
ja
JsonArrayThe JSON array.
Accepts
procedure Accepts(): Text
Gets the content type that is expected for the body of the request.
Parameters / Return Value
Returns
Text[]The requested content type.
Accepts
procedure Accepts(NewValue: Text): Text
Sets the content type that is expected for the body of the request.
Parameters / Return Value
NewValue
Text[]The content type to be set.
Returns
Text[]
ResponseStatus
procedure ResponseStatus(): Integer
Returns the HTTP status of the last response.
Parameters / Return Value
Returns
IntegerThe HTTP status.
ResponseStatusSuccess
procedure ResponseStatusSuccess(): Boolean
Returns true if the last response was succesful.
Parameters / Return Value
Returns
BooleanTrue of False.
ResponseBody
procedure ResponseBody(): Text
Returns the body of the last reposonse as a string.
Parameters / Return Value
Returns
Text[]The response as string.
ResponseBodyAsJsonObject
procedure ResponseBodyAsJsonObject(): JsonObject
Returns the body of the last reposonse, converting it to JSON object.
Parameters / Return Value
Returns
JsonObjectThe JSON object.
ResponseBodyAsJsonArray
procedure ResponseBodyAsJsonArray(): JsonArray
Returns the body of the last reposonse, converting it to JSON array.
Parameters / Return Value
Returns
JsonArrayThe JSON array.
ResponseBodyAsXmlDoc
procedure ResponseBodyAsXmlDoc(): XmlDocument
Returns the body of the last reposonse, converting it to an XML document.
Parameters / Return Value
Returns
XmlDocumentThe XML document.
ResponseBodyAsStream
procedure ResponseBodyAsStream(Result: InStream)
Returns the body of the last reposonse as a stream.
Parameters / Return Value
- Result
InStream
ResponseBodyAsTempBlob
procedure ResponseBodyAsTempBlob(var blob: Codeunit "Temp Blob")
Returns the body of the last reposonse as a TempBlob
Parameters / Return Value
- blob
Codeunit "Temp Blob"
ResponseHeaders
procedure ResponseHeaders(): HttpHeaders
Returns the headers of the last reposonse.
Parameters / Return Value
Returns
HttpHeadersThe response headers.
RemoveHeader
procedure RemoveHeader(HeaderKey: Text): Boolean
Removes an item from the request headers, if it exists
Parameters / Return Value
HeaderKey
Text[]The name of the header to be removed.
Returns
Booleantrueif the header was removed.falseotherwise.
SetHeader
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.
Parameters / Return Value
HeaderKey
Text[]The header key.
HeaderValue
Text[]The header value.
SetHeader
procedure SetHeader(HeaderKey: Text; HeaderValue: Text; Validate: Boolean)
Sets a request header to be used for the request.
Parameters / Return Value
HeaderKey
Text[]The header key.
HeaderValue
Text[]The header value.
Validate
BooleanSpecifies if the header value should be validated when sending the request.
SetHeader
procedure SetHeader(HeaderKey: Text; HeaderValue: SecretText; Validate: Boolean)
Sets a request header to be used for the request.
Parameters / Return Value
HeaderKey
Text[]The header key.
HeaderValue
SecretTextThe header value.
Validate
BooleanSpecifies if the header value should be validated when sending the request.
SendRequest
procedure SendRequest()
Sends the request. This is a TryFunction.
SendRequest
procedure SendRequest(HttpClient: HttpClient)
Sends the request using the given HTTP client. This is a TryFunction.
Parameters / Return Value
HttpClient
HttpClientThe HTTP client to use for sending.
SendRequest
procedure SendRequest(Resource: Text)
Sends the request to a given resource. The resource is appended to the base URI. This is a TryFunction.
Parameters / Return Value
Resource
Text[]The resource to be appended to the base URI.
SendRequest
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.
Parameters / Return Value
Resource
Text[]The resource to be appended to the base URI.
HttpClient
HttpClientThe HTTP client to use for sending.
ThrowIfNotSuccessStatus
procedure ThrowIfNotSuccessStatus()
Throws a generic error message if the request was not successful.
ResetResponse
procedure ResetResponse()
Resets all response-related properties.
SetServiceConfig
procedure SetServiceConfig(NewServiceConfig: Record "EOS004 Service Config.")
Parameters / Return Value
- NewServiceConfig
Record "EOS004 Service Config."
SetServiceConfig
procedure SetServiceConfig(NewServiceConfigCode: Code[20])
Parameters / Return Value
- NewServiceConfigCode
Code[20]
Events
OnAfterConfigureClient
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.
Parameters / Return Value
HttpClient
HttpClientThe HTTP client that has been configured.
OnBeforeSendRequest
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.
Parameters / Return Value
Request
HttpRequestMessageThe HTTP request about to be sent.
Feedback
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.