Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Business Central forum

Need to update salesOrderLines but can't figure out what salesOrderLineId is.

(0) ShareShare
ReportReport
Posted on by 20

Need to update salesOrderLines.
I know the call is PATCH /businesscentral/companies({id})/salesOrders({id})/salesOrderLines({salesOrderLineId})
But how do you get salesOrderLineId or what exactly is salesOrderLineId?
This call GET api.businesscentral.dynamics.com/.../companies({id})/salesOrders({id})/salesOrderLines does not return salesOrderLineId.
Any suggestions?
Thx
George

Categories:
  • Bsimon-AT Profile Picture
    15 on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    I have tried this many times with the data from my tenant.  

    Everything I try returns:

        <code>RequestDataInvalid</code>
        <message>Request data is invalid.</message>
    </error>
    When I use the GET:
    salesOrders(a3bba495-fc92-ea11-a813-000d3a9a95d6)/salesOrderLines?company=<stuff here>
    or
    salesOrders(a3bba495-fc92-ea11-a813-000d3a9a95d6)/salesOrderLines?company=<stuff here>&$filter=itemId eq a73bfe3b-208e-ea11-a813-000d3a9a9895
    I get the tag information to put in the header
    Once I follow the above instructions, I get the error seen above.
    I have tried using POST and PUT.  Same error.  my POST / PUT - yes those values exist, I copy and pasted them.
    salesOrders(a3bba495-fc92-ea11-a813-000d3a9a95d6)/salesOrderLines(documentId=(a3bba495-fc92-ea11-a813-000d3a9a95d6),sequence=(10000))
    Is there ANY other resource on this topic?  MS Documentation?  Anything?
  • Tiac Profile Picture
    30 on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    I am having the same issue, still not able to PUT to the salesOrderLines API. I finally was able to return the needed record using Stefano's suggestion (api.businesscentral.dynamics.com/.../salesOrderLines eq 10000) but cannot for the life of me get a PUT request to update the the shippedQuantity field (or any field for that matter).

    I was finally able to get this error:  

    <code>RequestDataInvalid</code>

    I made a PUT request to sandbox/api/v1.0/companies(246d9e77-cf80-4bba-8f28-5047c573a9cc)/salesOrders(52861b2e-8048-ea11-a812-000d3a72cf43)/salesOrderLines?$filter=sequence eq 10000 using basic auth and the If-Match properly in my Header with this as my body:

    {
    	"sequence":10000,
    	"shippedQuantity": 2
    }

    I have also tried this endpoint: sandbox/api/v1.0/companies(246d9e77-cf80-4bba-8f28-5047c573a9cc)/salesOrders(52861b2e-8048-ea11-a812-000d3a72cf43)   and also get the "Request data is invalid" error. Any guidance as to why I cannot updated the sales order line is much appreciated!

  • George Kre Profile Picture
    20 on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    Thank you,

    I will try your suggestion.

  • Verified answer
    I Gusti Made Ari Profile Picture
    3,594 on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    Hi George, here is what you need to do :

    1. Get the Etag for Sales Line that you want to update, in this example is line no. 10000

    GET salesOrders(0b57e18a-5d93-475e-b9d2-fe63a6e307dd)/salesOrderLines(documentId=(0b57e18a-5d93-475e-b9d2-fe63a6e307dd),sequence=(10000))

     "@odata.etag": "W/\"JzQwO1pCVUFBQUNSaXVGWEM1TmRYa2U1MHY1anB1TUgzUUNIRUNjQUFBQUExOzAwOyc=\"",

    Take note the etag response value .

    2.  Update the sales line for line no. 10000

    PATCH salesOrders(0b57e18a-5d93-475e-b9d2-fe63a6e307dd)/salesOrderLines(documentId=(0b57e18a-5d93-475e-b9d2-fe63a6e307dd),sequence=(10000))

    Take note at the request header you must put the etag from step 1 like below :

    IF-Match   value = W/"JzQwO1pCVUFBQUNSaXVGWEM1TmRYa2U1MHY1anB1TUgzUUNIRUNjQUFBQUExOzAwOyc="

    let say , you just want to change the quantity to 10 , put in the body like  below ( Sequence field is mandatory in the body) :

    {
    "sequence":10000,
    "quantity":10
    }

    Here is the result which i tried in postman :

    Gbr_5F00_978.png

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    If so, read the order with lines (expand). You can modify the lines and then send the entire order again (PATCH).

  • George Kre Profile Picture
    20 on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    I have already tried your second suggestion and no ID GUID.

    Also, if you check documentation here

    docs.microsoft.com/.../dynamics_salesorderline_get

    you will see no GUID in response.

    I think there is a glitch in API.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    Try using the salesOrder API with $expand=salesOrderLines

    Like:

    salesOrders(xxx)?$expand=salesOrderLines

    or retrieve the specific line with:

    salesOrders(xxx)/salesOrderLines?$filter=sequence eq 10000

    I cannot test now if the GUID is present. You can also post a SalesOrder object (PATCH) with the updated line. This will update the entire object.

  • George Kre Profile Picture
    20 on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    Thank you for your answer.

    Problem is that call GET api.businesscentral.dynamics.com/.../companies({id})/salesOrders({id})/salesOrderLines

    returns order lines but not IDs.

    It looks like a glitch in API.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Need to update salesOrderLines but can't figure out what salesOrderLineId is.

    If you read a Sales Order via API, you should have the ID of the record and the ID (GUID) of the lines. This is the ID that you need to use on your API.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans