HOW TO: Call A Codeunit Procedure By ODATA API Call in D365 Business Central/NAV

If you have a procedure written inside a Codeunit and want to invoke it from calling an API endpoint, here is how you can do it;

When a Codeunit is published as a web service in D365 Business Central, ODataV4 endpoint in unavailable and only SOAP URL is available.

You can however still call the Codeunit using an ODataV4 URL as it is called ‘unbound actions’. Following is an example taking you through it and testing it using Postman.

Let’s create a simple Codeunit with a Procedure and publish it as a web service.
A codeunit with a procedure that will return a text ‘mysamza.com’
Build the ODataV4 URL to invoke the MyProcedure() from MyCodeunit
{baseUrl}/ODataV4/Name-Of-The-Codeunit_Name-Of-The-Procedure?company=Name-Of-The-Company
Success
Response with Status 200 OK

Leave a Reply