Codeunit 5505375 M365 Rest Management

Codeunit 5505375 M365 Rest Management

Management Codeunit to handle REST API calls.

Methods

MethodGet

procedure MethodGet(): Enum "M365 Rest Request Method"

Constant for HTTP Method GET

Parameters / Return Value

  • Returns Enum "M365 Rest Request Method"

    Enum Get


MethodPost

procedure MethodPost(): Enum "M365 Rest Request Method"

Constant for HTTP Method POST

Parameters / Return Value

  • Returns Enum "M365 Rest Request Method"

    Enum Post


MethodPut

procedure MethodPut(): Enum "M365 Rest Request Method"

Constant for HTTP Method PUT

Parameters / Return Value

  • Returns Enum "M365 Rest Request Method"

    Enum Put


MethodDelete

procedure MethodDelete(): Enum "M365 Rest Request Method"

Constant for HTTP Method DELETE

Parameters / Return Value

  • Returns Enum "M365 Rest Request Method"

    Enum Delete


MethodPatch

procedure MethodPatch(): Enum "M365 Rest Request Method"

Constant for HTTP Method PATCH

Parameters / Return Value

  • Returns Enum "M365 Rest Request Method"

    Enum Patch


ContentTypeApplicationJson

procedure ContentTypeApplicationJson(): Text

Constant for HTTP Content Type application/json

Parameters / Return Value

  • Returns Text

    Text application/json


ContentTypeApplicationJsonPatchJson

procedure ContentTypeApplicationJsonPatchJson(): Text

Constant for HTTP Content Type application/json-patch+json

Parameters / Return Value

  • Returns Text

    Text application/json-patch+json


ContentTypeTextPlain

procedure ContentTypeTextPlain(): Text

Constant for HTTP Content Type text/plain

Parameters / Return Value

  • Returns Text

    Text text/plain


ContentTypeTextHtml

procedure ContentTypeTextHtml(): Text

Constant for HTTP Content Type text/html

Parameters / Return Value

  • Returns Text

    Text text/html


ContentTypeApplicationOctetStream

procedure ContentTypeApplicationOctetStream(): Text

Constant for HTTP Content Type application/octet-stream

Parameters / Return Value

  • Returns Text

    Text application/octet-stream


ContentTypeApplicationPdf

procedure ContentTypeApplicationPdf(): Text

Constant for HTTP Content Type application/pdf

Parameters / Return Value

  • Returns Text

    Text application/pdf


ContentTypeApplicationZip

procedure ContentTypeApplicationZip(): Text

Constant for HTTP Content Type application/zip

Parameters / Return Value

  • Returns Text

    Text application/zip


ContentTypeImageJpeg

procedure ContentTypeImageJpeg(): Text

Constant for HTTP Content Type image/jpeg

Parameters / Return Value

  • Returns Text

    Text image/jpeg


ContentTypeImagePng

procedure ContentTypeImagePng(): Text

Constant for HTTP Content Type image/png

Parameters / Return Value

  • Returns Text

    Text image/png


ContentTypeMultipartFormData

procedure ContentTypeMultipartFormData(): Text

Constant for HTTP Content Type image/png

Parameters / Return Value

  • Returns Text

    Text multipart/form-data


ContentTransferEncodingBase64

procedure ContentTransferEncodingBase64(): Text

Constant for HTTP Content Transfer Encoding base64

Parameters / Return Value

  • Returns Text

    Text base64


ContentTransferEncodingBinary

procedure ContentTransferEncodingBinary(): Text

Constant for HTTP Content Transfer Encoding binary

Parameters / Return Value

  • Returns Text

    Text binary


NewFormData

procedure NewFormData(var returnFormDataTempBlob: Codeunit "Temp Blob"; var returnFormDataStream: OutStream): Boolean

Initializes a new Form Data Temp Blob.

Parameters / Return Value

  • 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


FinishFormData

procedure FinishFormData(var formDataStream: OutStream)

Finishes a Form Data Temp Blob.

Parameters / Return Value

  • formDataStream OutStream

    The initialized form data stream pointing to the Temp Blob


AddFormDataPart

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.

Parameters / Return Value

  • 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


AddFormDataPart

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.

Parameters / Return Value

  • 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


AddFormDataPart

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.

Parameters / Return Value

  • 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


AddFormDataPart

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.

Parameters / Return Value

  • 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


AddFormDataPart

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.

Parameters / Return Value

  • 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


AddFormDataPart

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.

Parameters / Return Value

  • 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


AddFormDataPart

procedure AddFormDataPart(var formDataStream: OutStream; name: Text; value: Text): Boolean

Adds a form data part to the initialized form data Temp Blob.

Parameters / Return Value

  • 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


SetError

procedure SetError(newError: Text)

Adds an error text to the global error list.

Parameters / Return Value

  • newError Text

    Text describing the occured error


HasError

procedure HasError(): Boolean

Returns true, if an error has occured (the error list contains entries)

Parameters / Return Value

  • Returns Boolean

    true, if an error occured, false otherwise


GetError

procedure GetError(): Text

Returns the concatenated errors from the error list.

Parameters / Return Value

  • Returns Text

    The full error text


GetAndClearError

procedure GetAndClearError(): Text

Clears and returns the concatenated errors from the error list.

Parameters / Return Value

  • Returns Text

    The full error text


SetLogging

procedure SetLogging(newLoggingActive: Boolean)

Activates logging in a temporary table

Parameters / Return Value

  • newLoggingActive Boolean

    true if logging should be activated, false otherwise


SetAllowUnsecureAuthentication

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.

Parameters / Return Value

  • newAllowUnsecureAuthentication Boolean

    true if unsecure authentication is allowed, false otherwise


ShowLog

procedure ShowLog()

Shows the logged messages in a new page.


Initialize

procedure Initialize(newMethod: Text; newBaseUrl: Text; bodyTextEncoding: TextEncoding): Boolean

Initializes a new REST Request.

Parameters / Return Value

  • 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


Initialize

procedure Initialize(newMethod: Enum "M365 Rest Request Method"; newBaseUrl: Text; bodyTextEncoding: TextEncoding): Boolean

Initializes a new REST Request.

Parameters / Return Value

  • 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


Initialize

procedure Initialize(newMethod: Enum "M365 Rest Request Method"; newBaseUrl: Text): Boolean

Initializes a new REST Request.

Parameters / Return Value

  • 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


Initialize

procedure Initialize(newMethod: Text; newBaseUrl: Text): Boolean

Initializes a new REST Request.

Parameters / Return Value

  • 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


SetBasicAuthentication

procedure SetBasicAuthentication(userName: Text; password: Text): Boolean

Set the Authentication Method to Basic

Parameters / Return Value

  • userName Text

    The user name to use

  • password Text

    The password to use

  • Returns Boolean

    true if authentication could be set, false otherwise


SetBearerAuthentication

procedure SetBearerAuthentication(token: Text): Boolean

Set the Authentication Method to Bearer

Parameters / Return Value

  • token Text

    The Bearer token to use

  • Returns Boolean

    true if authentication could be set, false otherwise


SetDefaultWindowsAuthentication

procedure SetDefaultWindowsAuthentication(): Boolean

Sets Default/Integrated Windows Authentication

Windows Authentication is not supported in Cloud Deployments

Parameters / Return Value

  • Returns Boolean

    true if authentication could be set, false otherwise


SetWindowsAuthentication

procedure SetWindowsAuthentication(userName: Text; password: Text; domain: Text): Boolean

Sets Default/Integrated Windows Authentication

Windows Authentication is not supported in Cloud Deployments

Parameters / Return Value

  • 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


SetWindowsAuthentication

procedure SetWindowsAuthentication(userName: Text; password: Text): Boolean

Sets Default/Integrated Windows Authentication

Windows Authentication is not supported in Cloud Deployments

Parameters / Return Value

  • 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


AddDefaultRequestHeader

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)

Parameters / Return Value

  • 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


AddDefaultRequestHeader

procedure AddDefaultRequestHeader(newKey: Text; newValue: Variant)

Adds a default HTTP Request Header (see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields)

Parameters / Return Value

  • newKey Text

    The key to add as text

  • newValue Variant

    The value to add


SetContentType

procedure SetContentType(newContentType: Text)

Set the HTTP Request Content Type

See ContentTypeXXX() procedures.

Parameters / Return Value

  • newContentType Text

    The content type as text


AddBody

procedure AddBody(newBody: Text): Boolean

Add a Body to the HTTP Request

Parameters / Return Value

  • newBody Text

    The body as text

  • Returns Boolean

    true if the body could be added, false otherwise


AddBody

procedure AddBody(newBody: JsonObject): Boolean

Add a Body to the HTTP Request

Parameters / Return Value

  • newBody JsonObject

    The body as JsonObject

  • Returns Boolean

    true if the body could be added, false otherwise


AddBody

procedure AddBody(newBody: JsonArray): Boolean

Add a Body to the HTTP Request

Parameters / Return Value

  • newBody JsonArray

    The body as JsonArray

  • Returns Boolean

    true if the body could be added, false otherwise


AddBody

procedure AddBody(newBody: JsonToken): Boolean

Add a Body to the HTTP Request

Parameters / Return Value

  • newBody JsonToken

    The body as JsonToken

  • Returns Boolean

    true if the body could be added, false otherwise


AddBody

procedure AddBody(newBodyTempBlob: Codeunit "Temp Blob"): Boolean

Add a Body to the HTTP Request

Parameters / Return Value

  • newBodyTempBlob Codeunit "Temp Blob"

    The body as “Temp Blob” Codeunit

  • Returns Boolean

    true if the body could be added, false otherwise


AddBody

procedure AddBody(newBodyStream: InStream; blobTextEncoding: TextEncoding): Boolean

Add a Body to the HTTP Request

Parameters / Return Value

  • 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


AddBody

procedure AddBody(newBodyStream: InStream): Boolean

Add a Body to the HTTP Request

Parameters / Return Value

  • newBodyStream InStream

    The body as InStream

  • Returns Boolean

    true if the body could be added, false otherwise


LastResponseReasonPhrase

procedure LastResponseReasonPhrase(): Text

Returns the last Reason Phrase (description) of the returned status.

Parameters / Return Value

  • Returns Text

    The reason phrase as text


LastHttpStatusCode

procedure LastHttpStatusCode(): Integer

Returns the last HTTP Status Code (like 200, 400, …)

Parameters / Return Value

  • Returns Integer

    The status code as Integer


Send

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.

Parameters / Return Value

  • 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


Send

procedure Send(var response: HttpResponseMessage; raiseError: Boolean): Boolean

Sends the prepared REST Request to the configured destination.

Parameters / Return Value

  • 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


Send

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.

Parameters / Return Value

  • 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


Send

procedure Send(var response: HttpResponseMessage): Boolean

Sends the prepared REST Request to the configured destination.

Parameters / Return Value

  • response HttpResponseMessage

    This is a return value. The HttpResponseMessage from the destination

  • Returns Boolean

    true if the request has succeeded, false otherwise


GetResponseHeaders

procedure GetResponseHeaders(var response: HttpResponseMessage): HttpHeaders

Returns the Header Dictionary (HttpHeaders) contained in the passed HttpResponseMessage.

Parameters / Return Value

  • response HttpResponseMessage

    The response received from the destination

  • Returns HttpHeaders

    HttpHeaders contained in the response


GetResponseContentAsText

procedure GetResponseContentAsText(var response: HttpResponseMessage; var responseText: Text): Boolean

Returns the HTTP response content as text in responseText

Parameters / Return Value

  • response HttpResponseMessage

    The response received from the destination

  • responseText Text

    The full response text

  • Returns Boolean

    true if the response contains content, false otherwise


GetResponseContentAsJsonToken

procedure GetResponseContentAsJsonToken(var response: HttpResponseMessage; var responseJToken: JsonToken): Boolean

Returns the HTTP response content as a JsonToken.

Parameters / Return Value

  • 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


GetResponseContentAsJsonObject

procedure GetResponseContentAsJsonObject(var response: HttpResponseMessage; var responseJObject: JsonObject): Boolean

Returns the HTTP response content as a JsonObject.

Parameters / Return Value

  • 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


GetResponseContentAsJsonArray

procedure GetResponseContentAsJsonArray(var response: HttpResponseMessage; var responseJArray: JsonArray): Boolean

Returns the HTTP response content as a JsonArray.

Parameters / Return Value

  • 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



EOS Labs -