Skip to main content

Notifications

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

Update Sales Order Line using a custom API

Posted on by 25

Hi Experts,

I am facing an issue while update any field of Sales Order Line. Below are the details.

URL: api.businesscentral.dynamics.com/.../{SandBox Name}/api/v2.0/companies(Company Id)/salesOrders(SalesOrder ID)?$expand=salesOrderLines

with headers : Content-Type: Application/son, if-match: *

Body :  

{
    "prepayment"40,
    "salesOrderLines": [
        {
            "quantity"25,
            "unitPrice"2000,
        }
    ]
}
Response: 
{
"@odata.etag""W/\"JzIwOzEwMTIxNjUwMjAwMDU2MzY4ODQ2MTswMDsn\"",
            "no""1006",
            "documentType""Order",
            "selltoCustomerNo""C000001",
            "prepayment": 40,
            "salesOrderLines": []
     }
Categories:
  • Gianfranco C. Profile Picture
    Gianfranco C. 370 on at
    RE: Update Sales Order Line using a custom API

    hello, confirming the above.

    happy to have been of help.

    greetings

    Don't forget to help the community by Verifying the answer and Like it if your question has been answered. It will let others know that the topic has verified answer.

    Thanks & Regards,

    Gian

  • Khadija  Profile Picture
    Khadija 25 on at
    RE: Update Sales Order Line using a custom API

    thank you for all your responses.

    what i found with all my search that is impossible to update sales orders and sales line in the some time. so they updated separately with

    URL: api.businesscentral.dynamics.com/.../{SandBox Name}/api/v2.0/companies(Company Id)/salesOrderLines(SalesOrderLineID)

    for sales lines

    and

    URL: api.businesscentral.dynamics.com/.../{SandBox Name}/api/v2.0/companies(Company Id)/salesOrders(SalesOrder ID)

    for sales orders

  • Suggested answer
    Gianfranco C. Profile Picture
    Gianfranco C. 370 on at
    RE: Update Sales Order Line using a custom API

    I believe that the standard or custom copy of the standard cannot be made.
    You probably need a more structured code to take in all the information from the query url

  • Khadija  Profile Picture
    Khadija 25 on at
    RE: Update Sales Order Line using a custom API

    hello,

    URL: api.businesscentral.dynamics.com/.../{SandBox Name}/api/v2.0/companies(Company Id)/salesOrderLines(SalesOrderLineID)
    this is work for sales line but what i want is to update sales orders and sales line in the some time

    so i try this
    URL: api.businesscentral.dynamics.com/.../{SandBox Name}/api/v2.0/companies(Company Id)/salesOrders(SalesOrder ID)/salesOrderLines(SalesOrderLineID)

    but it give me an error

    {
    "error": {
    "code": "BadRequest",
    "message": "Invalid Request Body CorrelationId: 5647f519-9f22-4b87-bb30-2ef526b359ab."
    }
    }

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: Update Sales Order Line using a custom API

    Hi Khadija,

    this blog post might help you www.kauffmann.nl/.../

    also, check out Microsofts documentation learn.microsoft.com/.../dynamics_salesorderline_update

    Regards

  • Suggested answer
    Gianfranco C. Profile Picture
    Gianfranco C. 370 on at
    RE: Update Sales Order Line using a custom API

    hello, the correct call is this:

    Method:  PATCH

    URL: https://api.businesscentral.dynamics.com/.../{SandBox Name}/api/v2.0/companies(Company Id)/salesOrders(SalesOrder ID)/salesOrderLines(SalesOrderLineID)

    or

    URL: api.businesscentral.dynamics.com/.../{SandBox Name}/api/v2.0/companies(Company Id)/salesOrderLines(SalesOrderLineID)

    Headers:     Content-Type: Application/son, if-match: *

    Body :  

    {    
         "quantity": 25,
         "unitPrice": 2000,
    }

    Don't forget to help the community by Verifying the answer and Like it if your question has been answered. It will let others know that the topic has verified answer.

    Thanks & Regards,
    Gian

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!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans