Codeunit 5505375 M365 Rest Management
Management Codeunit to handle REST API calls.
procedure MethodGet(): Enum "M365 Rest Request Method"
Constant for HTTP Method GET
Returns Enum "M365 Rest Request Method"
Enum Get
procedure MethodPost(): Enum "M365 Rest Request Method"
Constant for HTTP Method POST
Returns Enum "M365 Rest Request Method"
Enum Post
procedure MethodPut(): Enum "M365 Rest Request Method"
Constant for HTTP Method PUT
Returns Enum "M365 Rest Request Method"
Enum Put
procedure MethodDelete(): Enum "M365 Rest Request Method"
Constant for HTTP Method DELETE
Returns Enum "M365 Rest Request Method"
Enum Delete
procedure MethodPatch(): Enum "M365 Rest Request Method"
Constant for HTTP Method PATCH
Returns Enum "M365 Rest Request Method"
Enum Patch
procedure ContentTypeApplicationJson(): Text
Constant for HTTP Content Type application/json
Returns Text
Text application/json
procedure ContentTypeApplicationJsonPatchJson(): Text
Constant for HTTP Content Type application/json-patch+json
Returns Text
Text application/json-patch+json
procedure ContentTypeTextPlain(): Text
Constant for HTTP Content Type text/plain
Returns Text
Text text/plain
procedure ContentTypeTextHtml(): Text
Constant for HTTP Content Type text/html
Returns Text
Text text/html
procedure ContentTypeApplicationOctetStream(): Text
Constant for HTTP Content Type application/octet-stream
Returns Text
Text application/octet-stream
procedure ContentTypeApplicationPdf(): Text
Constant for HTTP Content Type application/pdf
Returns Text
Text application/pdf
procedure ContentTypeApplicationZip(): Text
Constant for HTTP Content Type application/zip
Returns Text
Text application/zip
procedure ContentTypeImageJpeg(): Text
Constant for HTTP Content Type image/jpeg
Returns Text
Text image/jpeg
procedure ContentTypeImagePng(): Text
Constant for HTTP Content Type image/png
Returns Text
Text image/png
procedure ContentTypeMultipartFormData(): Text
Constant for HTTP Content Type image/png
Returns Text
Text multipart/form-data
procedure ContentTransferEncodingBase64(): Text
Constant for HTTP Content Transfer Encoding base64
Returns Text
Text base64
procedure ContentTransferEncodingBinary(): Text
Constant for HTTP Content Transfer Encoding binary
Returns Text
Text binary
procedure NewFormData(var returnFormDataTempBlob: Codeunit "Temp Blob"; var returnFormDataStream: OutStream): Boolean
Initializes a new Form Data Temp Blob.
returnFormDataTempBlob Codeunit "Temp Blob"
The initialized Temp Blob
returnFormDataStream OutStream
The initialized form data stream pointing to the Temp Blob
Returns Boolean
True if initialization was successful, false otherwiese
procedure FinishFormData(var formDataStream: OutStream)
Finishes a Form Data Temp Blob.
formDataStream OutStream
The initialized form data stream pointing to the Temp Blob
procedure AddFormDataPart(var formDataStream: OutStream; name: Text; var contentTempBlob: Codeunit "Temp Blob"; filename: Text; contentType: Text; contentTransferEncoding: Text): Boolean
Adds a form data part to the initialized form data Temp Blob.
formDataStream OutStream
A form data OutStream to add the part to
name Text
The parameter or part name
contentTempBlob Codeunit "Temp Blob"
File content contained in a Temp Blob
filename Text
A filename if the part represents a file
contentType Text
The content type of the part if different from the header
contentTransferEncoding Text
The content transfer encoding type of the part
Returns Boolean
True if the part could be added successfully, false otherwise
procedure AddFormDataPart(var formDataStream: OutStream; name: Text; value: Text; filename: Text; contentType: Text; contentTransferEncoding: Text): Boolean
Adds a form data part to the initialized form data Temp Blob.
formDataStream OutStream
A form data OutStream to add the part to
name Text
The parameter or part name
value Text
The value to add to the parameter or part
filename Text
A filename if the part represents a file
contentType Text
The content type of the part if different from the header
contentTransferEncoding Text
The content transfer encoding type of the part
Returns Boolean
True if the part could be added successfully, false otherwise
procedure AddFormDataPart(var formDataStream: OutStream; name: Text; var value: TextBuilder; filename: Text; contentType: Text; contentTransferEncoding: Text): Boolean
Adds a form data part to the initialized form data Temp Blob.
formDataStream OutStream
A form data OutStream to add the part to
name Text
The parameter or part name
value TextBuilder
The value to add to the parameter or part
filename Text
A filename if the part represents a file
contentType Text
The content type of the part if different from the header
contentTransferEncoding Text
The content transfer encoding type of the part
Returns Boolean
True if the part could be added successfully, false otherwise
procedure AddFormDataPart(var formDataStream: OutStream; name: Text; value: Text; filename: Text; contentType: Text): Boolean
Adds a form data part to the initialized form data Temp Blob.
formDataStream OutStream
A form data OutStream to add the part to
name Text
The parameter or part name
value Text
The value to add to the parameter or part
filename Text
A filename if the part represents a file
contentType Text
The content type of the part if different from the header
Returns Boolean
True if the part could be added successfully, false otherwise
procedure AddFormDataPart(var formDataStream: OutStream; name: Text; contentTempBlob: Codeunit "Temp Blob"; filename: Text; contentType: Text): Boolean
Adds a form data part to the initialized form data Temp Blob.
formDataStream OutStream
A form data OutStream to add the part to
name Text
The parameter or part name
contentTempBlob Codeunit "Temp Blob"
File content contained in a Temp Blob
filename Text
A filename if the part represents a file
contentType Text
The content type of the part if different from the header
Returns Boolean
True if the part could be added successfully, false otherwise
procedure AddFormDataPart(var formDataStream: OutStream; name: Text; fromStream: InStream; filename: Text; contentType: Text): Boolean
Adds a form data part to the initialized form data Temp Blob.
formDataStream OutStream
A form data OutStream to add the part to
name Text
The parameter or part name
fromStream InStream
A Stream containing the content
filename Text
A filename if the part represents a file
contentType Text
The content type of the part if different from the header
Returns Boolean
True if the part could be added successfully, false otherwise
procedure AddFormDataPart(var formDataStream: OutStream; name: Text; value: Text): Boolean
Adds a form data part to the initialized form data Temp Blob.
formDataStream OutStream
A form data OutStream to add the part to
name Text
The parameter name
value Text
The value to add to the parameter or part
Returns Boolean
True if the part could be added successfully, false otherwise
procedure SetError(newError: Text)
Adds an error text to the global error list.
newError Text
Text describing the occured error
procedure HasError(): Boolean
Returns true, if an error has occured (the error list contains entries)
Returns Boolean
true, if an error occured, false otherwise
procedure GetError(): Text
Returns the concatenated errors from the error list.
Returns Text
The full error text
procedure GetAndClearError(): Text
Clears and returns the concatenated errors from the error list.
Returns Text
The full error text
procedure SetLogging(newLoggingActive: Boolean)
Activates logging in a temporary table
newLoggingActive Boolean
true if logging should be activated, false otherwise
procedure SetAllowUnsecureAuthentication(newAllowUnsecureAuthentication: Boolean)
Usually Basic and Bearer authentication sending plain text password information through http. By default, an error is raised if the connection is not secured. Use this procedure to allow unsecure authentication.
newAllowUnsecureAuthentication Boolean
true if unsecure authentication is allowed, false otherwise
procedure ShowLog()
Shows the logged messages in a new page.
procedure Initialize(newMethod: Text; newBaseUrl: Text; bodyTextEncoding: TextEncoding): Boolean
Initializes a new REST Request.
newMethod Text
The Request Method as Text (GET, POST, PUT, DELETE, PATCH)
newBaseUrl Text
The Base URL of the REST service
bodyTextEncoding TextEncoding
The TextEncoding, which will be applied to the BodyStream
Returns Boolean
true if everything went ok, false otherwise
procedure Initialize(newMethod: Enum "M365 Rest Request Method"; newBaseUrl: Text; bodyTextEncoding: TextEncoding): Boolean
Initializes a new REST Request.
newMethod Enum "M365 Rest Request Method"
The Request Method as Enum “M365 Rest Request Method”
newBaseUrl Text
The Base URL of the REST service
bodyTextEncoding TextEncoding
The TextEncoding, which will be applied to the BodyStream
Returns Boolean
true if everything went ok, false otherwise
procedure Initialize(newMethod: Enum "M365 Rest Request Method"; newBaseUrl: Text): Boolean
Initializes a new REST Request.
newMethod Enum "M365 Rest Request Method"
The Request Method as Enum “M365 Rest Request Method”
newBaseUrl Text
The Base URL of the REST service
Returns Boolean
true if everything went ok, false otherwise
procedure Initialize(newMethod: Text; newBaseUrl: Text): Boolean
Initializes a new REST Request.
newMethod Text
The Request Method as Text (GET, POST, PUT, DELETE, PATCH)
newBaseUrl Text
The Base URL of the REST service
Returns Boolean
true if everything went ok, false otherwise
procedure SetBasicAuthentication(userName: Text; password: Text): Boolean
Set the Authentication Method to Basic
userName Text
The user name to use
password Text
The password to use
Returns Boolean
true if authentication could be set, false otherwise
procedure SetBearerAuthentication(token: Text): Boolean
Set the Authentication Method to Bearer
token Text
The Bearer token to use
Returns Boolean
true if authentication could be set, false otherwise
procedure SetDefaultWindowsAuthentication(): Boolean
Sets Default/Integrated Windows Authentication
Windows Authentication is not supported in Cloud Deployments
Returns Boolean
true if authentication could be set, false otherwise
procedure SetWindowsAuthentication(userName: Text; password: Text; domain: Text): Boolean
Sets Default/Integrated Windows Authentication
Windows Authentication is not supported in Cloud Deployments
userName Text
The Windows user name to use
password Text
The Windows password to use
domain Text
The Windows domain to use
Returns Boolean
true if authentication could be set, false otherwise
procedure SetWindowsAuthentication(userName: Text; password: Text): Boolean
Sets Default/Integrated Windows Authentication
Windows Authentication is not supported in Cloud Deployments
userName Text
The Windows user name to use
password Text
The Windows password to use
Returns Boolean
true if authentication could be set, false otherwise
procedure AddDefaultRequestHeader(newKey: Enum "M365 Rest Keyword Token"; newValue: Variant)
Adds a default HTTP Request Header (see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields)
newKey Enum "M365 Rest Keyword Token"
The key to add from the predefined Enum “M365 Rest Keyword Token” set.
newValue Variant
The value to add
procedure AddDefaultRequestHeader(newKey: Text; newValue: Variant)
Adds a default HTTP Request Header (see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields)
newKey Text
The key to add as text
newValue Variant
The value to add
procedure SetContentType(newContentType: Text)
Set the HTTP Request Content Type
See ContentTypeXXX() procedures.
newContentType Text
The content type as text
procedure AddBody(newBody: Text): Boolean
Add a Body to the HTTP Request
newBody Text
The body as text
Returns Boolean
true if the body could be added, false otherwise
procedure AddBody(newBody: JsonObject): Boolean
Add a Body to the HTTP Request
newBody JsonObject
The body as JsonObject
Returns Boolean
true if the body could be added, false otherwise
procedure AddBody(newBody: JsonArray): Boolean
Add a Body to the HTTP Request
newBody JsonArray
The body as JsonArray
Returns Boolean
true if the body could be added, false otherwise
procedure AddBody(newBody: JsonToken): Boolean
Add a Body to the HTTP Request
newBody JsonToken
The body as JsonToken
Returns Boolean
true if the body could be added, false otherwise
procedure AddBody(newBodyTempBlob: Codeunit "Temp Blob"): Boolean
Add a Body to the HTTP Request
newBodyTempBlob Codeunit "Temp Blob"
The body as “Temp Blob” Codeunit
Returns Boolean
true if the body could be added, false otherwise
procedure AddBody(newBodyStream: InStream; blobTextEncoding: TextEncoding): Boolean
Add a Body to the HTTP Request
newBodyStream InStream
The body as InStream
blobTextEncoding TextEncoding
The TextEncoding, which will be applied to the body
Returns Boolean
true if the body could be added, false otherwise
procedure AddBody(newBodyStream: InStream): Boolean
Add a Body to the HTTP Request
newBodyStream InStream
The body as InStream
Returns Boolean
true if the body could be added, false otherwise
procedure LastResponseReasonPhrase(): Text
Returns the last Reason Phrase (description) of the returned status.
Returns Text
The reason phrase as text
procedure LastHttpStatusCode(): Integer
Returns the last HTTP Status Code (like 200, 400, …)
Returns Integer
The status code as Integer
procedure Send(path: Text; var response: HttpResponseMessage; raiseError: Boolean): Boolean
Sends the prepared REST Request to the configured destination. If path is not empty, then path is added to the base request URL.
path Text
The path is added to the base request URL
response HttpResponseMessage
This is a return value. The HttpResponseMessage from the destination
raiseError Boolean
Set to true, if errors should be raised directly
Returns Boolean
true if the request has succeeded, false otherwise
procedure Send(var response: HttpResponseMessage; raiseError: Boolean): Boolean
Sends the prepared REST Request to the configured destination.
response HttpResponseMessage
This is a return value. The HttpResponseMessage from the destination
raiseError Boolean
Set to true, if errors should be raised directly
Returns Boolean
true if the request has succeeded, false otherwise
procedure Send(path: Text; var response: HttpResponseMessage): Boolean
Sends the prepared REST Request to the configured destination. If path is not empty, then path is added to the base request URL.
path Text
The path is added to the base request URL
response HttpResponseMessage
This is a return value. The HttpResponseMessage from the destination
Returns Boolean
true if the request has succeeded, false otherwise
procedure Send(var response: HttpResponseMessage): Boolean
Sends the prepared REST Request to the configured destination.
response HttpResponseMessage
This is a return value. The HttpResponseMessage from the destination
Returns Boolean
true if the request has succeeded, false otherwise
procedure GetResponseHeaders(var response: HttpResponseMessage): HttpHeaders
Returns the Header Dictionary (HttpHeaders) contained in the passed HttpResponseMessage.
response HttpResponseMessage
The response received from the destination
Returns HttpHeaders
HttpHeaders contained in the response
procedure GetResponseContentAsText(var response: HttpResponseMessage; var responseText: Text): Boolean
Returns the HTTP response content as text in responseText
response HttpResponseMessage
The response received from the destination
responseText Text
The full response text
Returns Boolean
true if the response contains content, false otherwise
procedure GetResponseContentAsJsonToken(var response: HttpResponseMessage; var responseJToken: JsonToken): Boolean
Returns the HTTP response content as a JsonToken.
response HttpResponseMessage
The response received from the destination
responseJToken JsonToken
The full response as a JsonToken
Returns Boolean
true if the response contains content, false otherwise
procedure GetResponseContentAsJsonObject(var response: HttpResponseMessage; var responseJObject: JsonObject): Boolean
Returns the HTTP response content as a JsonObject.
response HttpResponseMessage
The response received from the destination
responseJObject JsonObject
The full response as a JsonObject
Returns Boolean
true if the response contains content, false otherwise
procedure GetResponseContentAsJsonArray(var response: HttpResponseMessage; var responseJArray: JsonArray): Boolean
Returns the HTTP response content as a JsonArray.
response HttpResponseMessage
The response received from the destination
responseJArray JsonArray
The full response as a JsonArray
Returns Boolean
true if the response contains content, false otherwise
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.