Dynamics NAV 2018 API

Hi folks!!!

We are working with new Dynamics NAV API… all works well when we do POST, GET, PATCH and DELETE. I’ve created a new Page API for journals, because the standard journal API si very limited (it only allows G/L accounts, and only can read/create/modify/delete, but not posting).

I’ve been searching for a Page API to post a sales invoice… observing current Page API for sales invoice (5475 Sales Invoice Entity), I’ve seen a few functions classified as “External” (visibility) and “ServiceEnabled”. In fact, when I look for API metadata in:


The system shows my, all data definitions for the API, including those functions defined as “External” and “ServiceEnabled” in their properties… in the case of sales invoice, I can see 5 actions:

<Action Name="Post" IsBound="true">
    <Parameter Name="bindingParameter" Type="Microsoft.NAV.salesInvoice" />
<Action Name="PostAndSend" IsBound="true">
    <Parameter Name="bindingParameter" Type="Microsoft.NAV.salesInvoice" />
<Action Name="Send" IsBound="true">
    <Parameter Name="bindingParameter" Type="Microsoft.NAV.salesInvoice" />
<Action Name="Cancel" IsBound="true">
    <Parameter Name="bindingParameter" Type="Microsoft.NAV.salesInvoice" />
<Action Name="CancelAndSend" IsBound="true">
    <Parameter Name="bindingParameter" Type="Microsoft.NAV.salesInvoice" />

The question is: how can I access to these actions? How can I post a sales invoice from API using “Post” action?

I found how to do it!!!

You have to do a POST to an invoice ID, following this:

http://YourServer:YourOdataServicePort/YourServiceName/api/beta/[companies(company id)/]salesInvoices(invoice Id)/Microsoft.NAV.Post

“companies” part is necessary if you don’t have a default company in service configuration or you need to post over more than a company.

Be careful with capital letters, write “Microsoft.NAV.Post” this way.

Good work finding it out yourself. And you are indeed right this is one very good way of doing it.

You could also just create a new codeunit - with a function ind it as



SalesHeader.Invoice := TRUE;

SalesHeader.Ship := TRUE;

IF Not SalesHeaderPost.(SalesHeader) then


You then have to remember to make the function in the codeunit PUBLIC.

Something like the above :slight_smile:

Hi Palle!!!

I was thinking in other ways to do that (in fact, in my personalized journal API I implemented a method trough a new control in the page and works very well), but I prefer to use the action provided by API… it was very anouying seeing the action and was not able to use it properly!!!

Otherwise, if anyone try to use your example, he has to bear in mind that Sales header has a “Document type”, but the idea is the important thing, and is a good one.

Best regards!!!

Thanks for that insight!