web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Issue with Creating Sales Lines in Business Central API (Custom Pages)

(2) ShareShare
ReportReport
Posted on by 12

I am working on creating custom API pages for SalesHeader and SalesLine in Dynamics 365 Business Central. While I am able to successfully create a Sales Quote (the SalesHeader), the associated SalesLine is not being created as expected. I am using the following structure to link the SalesLine to the SalesHeader:

part(salesLines; "SalesLine")
{
SubPageLink = "Document No." = field("No.");
}
Here is my JSON for creating a Sales Quote with a SalesLine:
POST
https://api.businesscentral.dynamics.com/v2.0/{Sanbox Name}/api/{ApiPublisher}/{ApiGroup}/v1.0/companies({CompanyID})/SalesHeader
{
"billtocustomerno": "10000",
"documenttype": "Quote",
"selltocustomerno": "10000",
"salesLine": [
{
"area": "",
"description": "Iphone",
"genBusPostingGroup": "DOMESTIC",
"genProdPostingGroup": "RETAIL",
"itemCategoryCode": "CHAIR",
"itemReferenceNo": "",
"itemReferenceTypeNo": "",
"itemReferenceUnitOfMeasure": "",
"locationCode": "BLUE",
"netWeight": 0,
"no": "1000",
"quantity": 5,
"type": "Item",
"unitOfMeasure": "Piece",
"useDuplicationList": false
}
]
}
The Sales Quote is created successfully, but the SalesLine is not created. There are no errors in the response, and everything looks fine, but the SalesLine data doesn't appear.
I then attempted to post the SalesLine separately to the SalesHeader like this:
POST
https://api.businesscentral.dynamics.com/v2.0/{Sanbox Name}/api/{ApiPublisher}/{ApiGroup}/v1.0/companies({CompanyID})/SalesHeader({SalesQuoteID})/SalesLine

{
"area": "",
"description": "Iphone",
"documentNo": "1021",
"documentType": "Quote",
"genBusPostingGroup": "DOMESTIC",
"genProdPostingGroup": "RETAIL",
"itemCategoryCode": "CHAIR",
"itemReferenceNo": "",
"itemReferenceTypeNo": "",
"itemReferenceUnitOfMeasure": "",
"locationCode": "BLUE",
"netWeight": 0,
"no": "1000",
"quantity": 5,
"type": "Item",
"unitOfMeasure": "Piece",
"useDuplicationList": false
}
However, I received this error:
{
"error": {
"code": "Internal_RecordNotFound",
"message": "The Standard Text does not exist. Identification fields and values: Code='1000' CorrelationId: fb5171a4-1b6c-49c2-a3bb-9d62955d229c."
}
}
Next, I tried removing the no field from the SalesLine data. The SalesLine was created successfully, but the item data was not reflected.
I also tried using the PATCH method to update the SalesLine, but the update did not seem to take effect.

I have the same question (0)
  • Gerardo Rentería García Profile Picture
    25,388 Most Valuable Professional on at

    Hi, good day
    I hope this can help you, and give you some hints.

    How to create Sales Order through Postman in Business Central - Ivan Singleton

    Best Regards
    Gerardo

  • Suggested answer
    YUN ZHU Profile Picture
    95,761 Super User 2025 Season 2 on at
    Hi, hope the following helps.
    Deep insert with Business Central APIs (part 2)
     
    Thanks.
    ZHU
  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at
    Navigate to Table 37 and check if record is inserted with the input data after running the API.
    Also check if Document Type and Document No. fields are updated properly as header.
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,947 Super User 2025 Season 2 on at

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,126

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 744 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 674 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans