Call web services with AL Rest Client module

Important

This content is archived and is not being updated. For the latest documentation, go to What's new or changed in Business Central. For the latest release plans, go to Dynamics 365, Power Platform, and Cloud for Industry release plans.

Enabled for Public preview General availability
Users, automatically - Nov 3, 2023

Business value

The new AL Rest Client module contains methods to support calling web services with just one line of code, creating request content and reading the response from different types of data and authenticating using basic authentication.

Feature details

The new AL Rest Client module contains methods to support the following scenarios:

  • Calling web services with just one line of code.
  • Creating request content from Text, JSON, XML, or binary data.
  • Read the response as Text, JSON, XML, or binary data.
  • Authenticate using basic authentication.

Here are examples of new methods:

// Getting text
ResponseText := ALRestClient.Get(Url).Content().AsText();

// Getting binary data
TempBlob := ALRestClient.Get(Url).Content().AsBlob();

// Posting binary data and returning binary data
ALHttpContent.Create(TempBlob) TempBlob := ALRestClient.Post(Url, ALHttpContent).Content().AsBlob();

// Getting a JsonObject
JsonObject := ALRestClient.GetAsJson(Url).AsObject();

// Posting a JsonObject and returning the result as JsonObject
JsonObject := ALRestClient.PostAsJson(Url, JsonObject).AsObject();

// Using Basic Authentication
HttpAuthenticationBasic.Initialize('user01', 'Password123'); ALRestClient.Initialize(HttpAuthenticationBasic); ALHttpResponseMessage := ALRestClient.Get('https://httpbin.org/basic-auth/user01/Password123');

Note

We'd like to thank our community for making this valuable contribution through our System Application open-source repo on GitHub

Tell us what you think

Help us improve Dynamics 365 Business Central by discussing ideas, providing suggestions, and giving feedback. Use the forum at https://aka.ms/bcideas.

See also

System.RestClient (docs)