Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Business central API Sales Order Line POST

Posted on by Microsoft Employee

Hello all!

We are using Business Central API for Sales Order lines posting. docs.microsoft.com/.../dynamics_create_salesorderline
When we trying to post line for item which doesn't have enough stock we receive following error:

Exception: Something went wrong, see content for more details: {"error":{"code":"Internal_RecordNotFound","message":"The Sales Line does not exist. Identification fields and values: Document Type='Order',Document No.='1601',Line No.='10000' CorrelationId: 3ef083b4-c7f2-40f6-a109-c86690aecf57."}}

When we try to create exactly same order (with same quantities in line) in Business central it successfully created and just give us a warning about stock.
Can someone suggest us please, how we can avoid this error in API? Or maybe we need to add something into information we posting?

Thanks in advance!

Categories:
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Business central API Sales Order Line POST

    Thanks for your reply Jack!

    We use normal MBC API, not our custom AL API Page

    Can you tell me please,  based on your answer i understand that this is more issue about validation time. But when we do insert in MBC itself (by hands) we don't have any errors at all and line succesfullt created even after validation.

    So maybe API has some additional validation steps which not allow us to insert lines without stock? Or we can enable\disable some settings in MBC to use it smae way as it in MBC itself?

  • Suggested answer
    Jack Davies Profile Picture
    Jack Davies 120 on at
    RE: Business central API Sales Order Line POST

    This sounds like more a timing issue...(as in the API is creating the sales line and validating the fields without inserting the record (and then a piece of code is looking for that line)). Whereas when you do the same with your fingers in the client one of the controls/ validations of the sales order subpage is inserting the record before the qty is validated.

    If you can edit the API page - convert it to source table temporary, and the via the OnInsert/OnModify/... triggers code the creation of the sales lines to insert and then validate your remaining fields...

    or

    Change you API calls to be a POST simply creating the sales line, and then a second call to  PATCH the created sales line with the remaining fields

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans