Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

How to call the code unit 90 Purch.-Post from the Rest API

Posted on by 5

In Business Central under the webservices I have added the CodeUnit 90 "Purch.-Post" and named it PurchaseOrderPost

pastedimage1678178269365v1.png

From PostMan I'm trying to call the CodeUnit using the ODataV4 URL:

{{BusinessCentralURL}}/{{TenantId}}/{{Environment}}/ODataV4/PurchaseOrderPost

In the headers I pass the Company Id:

pastedimage1678178577602v2.png

I havn't found a way to pass the PurchaseOrder number or ID.

I'm using the OAuth 2.0 authorization

pastedimage1678178666178v3.png

The URL, TenantId and Environment are parameters, that are reused in multiple calls, for example:

{{BusinessCentralURL}}/{{TenantId}}/{{Environment}}/ODataV4/Company('CRONUS%20Danmark%20A%2FS')/PurchaseOrderPage?No='106001' - which works fine.

The response is "Resource not found for the segment 'PurchaseOrderPost'"

and looks like this:

pastedimage1678178785353v4.png

Has anybody successfully called the code unit 90 Purch.-Post? and would you please share how to?

  • ManishS Profile Picture
    ManishS 6,578 on at
    RE: How to call the code unit 90 Purch.-Post from the Rest API

    you need to create a new codeunit were in you need to set all the values using events i.e. receive, what will be the purchase order number. After that call purchase post codeunit.

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,333 Super User 2024 Season 2 on at
    RE: How to call the code unit 90 Purch.-Post from the Rest API

    Hi, as Mohana mentioned, you need to create a custom API at this time. Generally, there are two solutions.

    Creating and Interacting with an OData V4 Bound Action: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-creating-and-interacting-with-odatav4-bound-action

    Add custom execute actions: https://yzhums.com/20111/

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,127 Super User 2024 Season 2 on at
    RE: How to call the code unit 90 Purch.-Post from the Rest API

    then you may have to create a custom API page (copy of 30066 API) and set only receive to true in PostInvoice function

  • KlausJuhl Profile Picture
    KlausJuhl 5 on at
    RE: How to call the code unit 90 Purch.-Post from the Rest API

    Thanks Mohana, I did consider this, but I only want to receive the lines, not invoice

    I'm looking for the equivalent to the first option in the purchase order booking popup (receive only):

    pastedimage1678190049676v1.png

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,127 Super User 2024 Season 2 on at
    RE: How to call the code unit 90 Purch.-Post from the Rest API

    I was able to successfully use the below

    api.businesscentral.dynamics.com/.../NAV.ReceiveAndInvoice

    I published 30066 page as purchaseOrders

  • KlausJuhl Profile Picture
    KlausJuhl 5 on at
    RE: How to call the code unit 90 Purch.-Post from the Rest API

    I tried with and without the ODataV4 in the URL, same result.

    Any suggestions on how to pass the Company and PuchaseOrder number/ID ?

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: How to call the code unit 90 Purch.-Post from the Rest API

    hi

    try this

    Method: POST

    URI: api.businesscentral.dynamics.com/.../{MyNameWS}

    Authorization: Bearer + Access Token

    DAniele

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans