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:
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:
The key here is to add a PATCH method to the HttpRequestMessage object and then calling the Send method of HttpClient.
Easy and powerful 😉
Reblogged this on Mark Brummel Blog | Microsoft Dynamics NAV.
LikeLike