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
I have tried this many times with the data from my tenant.
Everything I try returns:
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:
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!
Thank you,
I will try your suggestion.
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 :
If so, read the order with lines (expand). You can modify the lines and then send the entire order again (PATCH).
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.
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.
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.
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.