Skip to main content

Notifications

Community site session details

Community site session details

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

Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

(0) ShareShare
ReportReport
Posted on by

Hi!

I would like to know if there is a way to trigger the Posting -> Post -> Ship action (no invoice) for Sales Order using the OData Web Services, SOAP Web Services or API Endpoints

pastedimage1632849270594v1.png

I already saw this bound actions but i would like to make the same without the invoice stuff.

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/resources/dynamics_salesorder#bound-actions

pastedimage1632849644568v2.png

King regards!

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    Please go through the link and try to understand the process.

  • agaonkar Profile Picture
    25 on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    Thanks for the link. But I am not able to understand anything.

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    Please go through the below link:

    community.dynamics.com/.../posting-invoices-using-apis

  • agaonkar Profile Picture
    25 on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    I tried the following:

    api.businesscentral.dynamics.com/.../Microsoft.NAV.shipAndInvoice

    where e75cee00-b718-ed11-90eb-000d3a54b3bc is my salesorder id and the request body is

    {

       "number": "S-ORD101011"

    }

    Response is:

    {

       "error": {

           "code": "BadRequest",

           "message": "One or more errors occurred.  CorrelationId:  2a39d66e-3719-4980-be0c-cfcb326dc36c."

       }

    }

    Is there anything wrong?

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    You have to supply sales order no. filter within your api to perform the Ship and invoice action.

    Thanks.

  • agaonkar Profile Picture
    25 on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    Hi there,

    Could you please help me with the request body for the API call

    api.businesscentral.dynamics.com/.../Microsoft.NAV.shipAndInvoice

    Currently I am not supplying anything and it says 

    {
        "error": {
            "code""Application_DialogException",
            "message""Please add at least one line item to the estimate.  CorrelationId:  98d53cd2-b0d3-4962-ab8f-5be785418ff8."
        }
    }
  • Samantha73 Profile Picture
    2,780 on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    Awesome ...Not a lot of info out there on APIs and some are not there to start with like AP credits...good thing is you can create bound actions or unbound. If performance is key unbound is recommended

  • Suggested answer
    jcdlm Profile Picture
    on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    Finally I solved my problem,

    First of all, I follow this guide to configure AL environment in Visual Studio Code

    docs.microsoft.com/.../devenv-get-started

    Then, downloaded this github repo

    github.com/.../ALAppExtensions

    In the APIV2SalesOrders.Page.al file, I found shipAndInvoice procedure, so I modified it as Samantha said and added the new code to my custom page.

    Then I published as a Web Service and now Im able to trigger this actions using OdataV4

    Hope it helps for someone with same needed.

    Kind regards!

  • jcdlm Profile Picture
    on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    Hello Samantha,

    Thanks for answering.

    Where did u get that code from?

  • Verified answer
    Samantha73 Profile Picture
    2,780 on at
    RE: Posting Ship Sales Order with OData WS / SOAP WS / API(v2.0)

    You can copy existing API and create your own. In the new API, comment out below code and create new procedure or rename existing to something like shipOnly(not a requirement just best practise):

       local procedure PostWithShipAndInvoice(var SalesHeader: Record "Sales Header"; var SalesInvoiceHeader: Record "Sales Invoice Header")

       var

           DummyO365SalesDocument: Record "O365 Sales Document";

           LinesInstructionMgt: Codeunit "Lines Instruction Mgt.";

           O365SendResendInvoice: Codeunit "O365 Send + Resend Invoice";

           OrderNo: Code[20];

           OrderNoSeries: Code[20];

       begin

           O365SendResendInvoice.CheckDocumentIfNoItemsExists(SalesHeader, false, DummyO365SalesDocument);

           LinesInstructionMgt.SalesCheckAllLinesHaveQuantityAssigned(SalesHeader);

           OrderNo := SalesHeader."No.";

           OrderNoSeries := SalesHeader."No. Series";

           SalesHeader.Ship := true;

           //SalesHeader.Invoice := true;//

           SalesHeader.SendToPosting(Codeunit::"Sales-Post");

           SalesInvoiceHeader.SetCurrentKey("Order No.");

           SalesInvoiceHeader.SetRange("Pre-Assigned No. Series", '');

           SalesInvoiceHeader.SetRange("Order No. Series", OrderNoSeries);

           SalesInvoiceHeader.SetRange("Order No.", OrderNo);

           SalesInvoiceHeader.FindFirst();

       end;

    Note: You also need to change few other bits since API looking for created invoice number so find that code but above works as is though u get a error response but order is shiped

    /salesOrders(4bac2cec-1821-ec11-8f46-00224810896b)/Microsoft.NAV.shipOnly

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,000 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,850 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans