Execute a PATCH call from an Extension by using AL and HttpClient

Stefano Demiliani

If you work with REST APIs, you already know that you’ve two HTTP methods for updating resources:

  • PUT: updates an entire resource
  • PATCH: the update request only needs to contain the changes to the resource, not the complete resource.

The AL language permits you to work with REST services by using the HttpClientclass. If you declare an HttpClient object in AL, from Intellisense in Visual Studio Code you can see that you have the following methods for working with resources:

HTTPClientPatch_01.jpg

Where is Patch?? How can I perform a Patch REST call? Is this not supported?

The answer is no, the solution to perform a Patch request is just a bit hidden (don’t ask me why 🙂 ). Here is how you can send a Patch request to a REST resource from AL:

HTTPClientPatch_02.jpg

The key here is to add a PATCH method to the HttpRequestMessage object and then calling the

View original post 9 more words

One thought on “Execute a PATCH call from an Extension by using AL and HttpClient

  1. Brian Juhl

    Hi Mark
    Funny you made this post, as I was working with the Send function on HttpClient.
    But BC is crashing and restarting when i touch HttpRequestMessage,
    So when i use Request.Content or Request.Method, which ever comes first in my code, then it crashes.
    Have you experienced this?
    Im on BC Online Sandbox.

    Like

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s