API V25 Insert Sales Header / Sales Line issue (API V 2.0)

  • API V25 Insert Sales Header / Sales Line issue (API V 2.0)

    Posted by Jeff Woodard on November 25, 2024 at 9:04 pm

    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&gt;)/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&gt;)/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.

    Jeff Woodard replied 3 weeks, 2 days ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.

Welcome to our new site!

Here you will find a wealth of information created for people  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!