web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

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

Stefano Demiliani Profile Picture Stefano Demiliani 37,166 Most Valuable Professional

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 HttpClient class. 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 Send method of HttpClient.

Easy and powerful

 


This was originally posted here.

Comments

*This post is locked for comments