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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Posting invoices using ODatav4 service

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I am making ODATAv4 requests to a Dynamics 365 BC instance (NAV 14.0).

I am trying to post invoices (not POST as in the HTTP method, but post as in 'move the invoice from draft status into the customer ledger' etc.). It's not working.

Here is the request I am making and the error message I get back

POST ?..blah/Company('CompanyABC')/SalesInvoice('Invoice','489362')/NAV.Post

{
"error":
    {
        "code": "Unknown",
        "message": "Object reference not set to an instance of an object."
    }
}

I've also tried /Microsoft.NAV.post

I have changed the visibility of the post function on the SalesInvoice page to external and enabled the service as follows, as below:

3286.al.png

But this did not fix the problem. I don't even know if I am hitting the function when I send the OData request.

I've looked at the following pages (and a lot more in the same vein) but I can't figure it out:

mydynstories.wordpress.com/.../
docs.microsoft.com/.../walkthrough-creating-and-interacting-odata-v4-bound-action
community.dynamics.com/.../905582

Can anyone suggest what I can do to fix this? I think I must be missing something obvious.

Simple suggestions are welcomed as I am a complete Dynamics novice.

I have the same question (0)
  • mark_truran Profile Picture
    5 on at
    RE: Posting invoices using ODatav4 service

    Hi Suresh,

    Thank you for replying again.

    I read through the article. I have a fair bit of background reading to do before I can understand it properly. I'll get on with that.

    In the meantime, someone has suggested running a batch job to auto-post sales invoices every hour or so. I'm hoping that will help us.

    Kind regards,

    Mark

  • Verified answer
    Suresh Kulla Profile Picture
    49,414 Super User 2025 Season 2 on at
    RE: Posting invoices using ODatav4 service

    You can find one example here

    docs.microsoft.com/.../walkthrough-creating-and-interacting-odata-v4-bound-action

  • mark_truran Profile Picture
    5 on at
    RE: Posting invoices using ODatav4 service

    Hi Suresh,

    Thanks for replying to my question. I really appreciate it. I have almost zero experience with Dynamics and I am finding it very difficult.

    I'd hoped that posting a draft invoice would be easy, but I am still stuck, even with your advice.

    Are you saying that I need to add a new function to the Sales Invoice page (43) using the Nav development environment (in the C/AL tab/section). Something like

    [External] [ServiceEnabled] MyPostingFunction (InvoiceNumber: Integer)

    And then add code to this function that somehow posts that sales invoice?

    Then call it like

    POST ​..blah/Company('CompanyABC')/SalesInvoice('489362')/NAV.MyPostingFunction

    Do you know of any walk-throughs that explain how to do this? I am struggling to find decent examples.

    Kind regards,

    Mark

  • Suggested answer
    Suresh Kulla Profile Picture
    49,414 Super User 2025 Season 2 on at
    RE: Posting invoices using ODatav4 service

    The above function has two parameters the codeunit id and the navigate option and I don't think you are passing right parameters. I would recommend create a new function with accepts invocie no. as parameters and enabled that function and use that.

  • mark_truran Profile Picture
    5 on at
    RE: Posting invoices using ODatav4 service

    I forgot to mention - The sales invoice does exist (I can GET it with an OData request with the same keys).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,857

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 2,687 Super User 2025 Season 2

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,203

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans