purchaseInvoiceLines endpoint does not accept Resource Item type custom unit cost
When posting to the api/v2.0/companies({{companyId}})/purchaseInvoiceLines endpoint using this body:
{
"documentId": "{docId}",
"lineType": "Resource",
"lineObjectNumber": "LINDA",
"description": "bbb",
"unitCost": 20,
"quantity": 2
}
The unit cost of the post body is ignored and instead uses the default resource item unit cost, it returns with this body in the result.
{ ... "id": {newId}, "documentId": "{docId}, "itemId": "00000000-0000-0000-0000-000000000000", "accountId": "00000000-0000-0000-0000-000000000000", "lineType": "Resource", "lineObjectNumber": "LINDA", "description": "bbb", "unitOfMeasureCode": "HOUR", "unitCost": 50, "quantity": 2, "taxCode": "REDUCED", "taxPercent": 5, "netAmount": 100, "netTaxAmount": 5, "netAmountIncludingTax": 105, ... }
Hi @Iamabdul . I suggest you yo change the order in statement, put "quantity" before "unitcost" that should solve the problem. Let me know about the result.
@Iamabdul , I also see you use purchaseInvoiceLines for exposure that doesn't look like existing in BC page. So also please try your request on the purchaseDocumentLines and share the result.
Hi @Iamabdul . Any update from your side?
@RomanZanizdra Apologies for the late reply!
I've attempted to put "quantity" before "unitcost" and that didn't work unfortunately.
I'm also using this page, I'm assuming that this is what this endpoint hits?:
api.businesscentral.dynamics.com/v2.0/sandbox/api/v2.0/companies({{companyId}})/purchaseInvoiceLines
Hi,
This is an issue with not only API but also web client. Changing quantity resets direct unit cost. We have logged an internal work item to track the issue.
As a workaround you can make one more PATCH call to unitCost after the POST request:
PATCH api/v2.0/companies({{companyId}})/purchaseInvoiceLines({{purchaseInvoiceLineId}}) { "unitCost": 50 }