API V25 Insert Sales Header / Sales Line issue (API V 2.0)
-
API V25 Insert Sales Header / Sales Line issue (API V 2.0)
Hi there BC Community. New to BC guy here trying to insert a simple sales header and sales line using a custom API. Nothing crazy here, just adding a few custom columns to each table, but I can’t insert the sales line no matter what I’ve tried. The custom APIs have no custom logic and only have the field names needed. Any advice would be greatly appreciated!
Using Postman, I can insert the sales header just fine as follows:
POST https://api.businesscentral.dynamics.com/v2.0/<TenantGuid>/Development/api/sib/siboney/v2.0/Companies(<companyGuid>)/sibSalesHeaders
{
"no": "TEST001",
"documentType": "Order",
"documentDate": "2024-11-25",
"billToCustomerNo": "21431",
"sellToCustomerNo": "21431"
}When I try this at the sales line level:
POST https://api.businesscentral.dynamics.com/v2.0/<TenantGuid>/Development/api/sib/siboney/v2.0/Companies(<companyGuid>)/sibSalesLines
{
"documentNo": "TEST001",
"documentType": "Order",
"No": "FUEL",
"type": "Item",
"quantity": 1,
"unitPrice": 1.00
}I’m getting this error:
The field Document No. of table Sales Line contains a value (TEST001) that cannot be found in the related table (Sales Header).
I do see the header in BC, as confirmed by copy/paste of the document number in the JSON above, and viewing in the page inspector.
I can insert the line using the OOB API if I pass the systemid GUID (documentId) of the header record instead of the document number, but unfortunately, the VS Code environment won’t let me add the salesLine.documentId to the API.
Sorry, there were no replies found.
Log in to reply.