Skip to main content

Notifications

Announcements

No record found.

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

Cannot create Sale Order through API

(0) ShareShare
ReportReport
Posted on by 5

I've got this error while trying to create sale order through API.

Every thing is set up following the guide line, but still got error. Already try different content-type (application/json;odata.metadata=minimal;EEE754Compatible=true)  but also not work.

{
    "error": {
        "code": "BadRequest",
        "message": "Invalid Request Body  CorrelationId:  9b68df58-b11a-4485-8069-84f8e2b06384."
    }
}
My request body:
{
    "customerNumber": "1728",
    "orderDate": "2023-05-30",
    "postingDate": "2023-05-30",
    "billToCustomerNumber": "1728",
    "sellToAddressLine1": "BLK 704 ANG MO KIO AVENUE 8",
    "sellToAddressLine2": "#01-2559",
    "sellToCity": "",
    "sellToState": "",
    "sellToCountry": "",
    "sellToPostCode": "560704",
    "shipToAddressLine1": "BLK 704 ANG MO KIO AVENUE 8",
    "shipToAddressLine2": "#01-2559",
    "shipToCity": "",
    "shipToState": "",
    "shipToCountry": "",
    "shipToPostCode": "560704"
}


pastedimage1683934546029v2.png
  • Suggested answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 on at
    RE: Cannot create Sale Order through API

    Hope this helps 

    [View:https://youtu.be/TSQiE42tDwU:320:240]

  • Suggested answer
    Ramiz Profile Picture
    Ramiz 344 on at
    RE: Cannot create Sale Order through API

    Hi Nam Ta 

    Please have a look at here. You can see the API pages.

    Also please check the API URL as well.

    learn.microsoft.com/.../dynamics_salesorder_create

  • Nam Ta Profile Picture
    Nam Ta 5 on at
    RE: Cannot create Sale Order through API

    Hi @Gian,

    As API is automatically generated by web service in Business central, I don't see it should be the cause here. Anw, I tried to use company id it's still got same error

  • Nam Ta Profile Picture
    Nam Ta 5 on at
    RE: Cannot create Sale Order through API

    Hi Ramiz , I tried to send only customer number but  the error is consistent. Do you have any suggestion where can I find information about proper names or  fields inthe API page?

  • Suggested answer
    Ramiz Profile Picture
    Ramiz 344 on at
    RE: Cannot create Sale Order through API

    Hi Nam Ta 

    This is very common error when you are passing a value in JSON that doesn't exit on the API Pages or the name that you have put in JSON is wrong.

    Please check all of the fields are available in the sales order API page and with same name. customerNumber, OrderDate etc.

    You can also test it by passing only the customerNumber and see if it is inserting the record or not. If it gets inserted then your JSON has some field thats not available on the API page.

    {
        "customerNumber": "1728",
        "orderDate": "2023-05-30",
        "postingDate": "2023-05-30",
        "billToCustomerNumber": "1728",
        "sellToAddressLine1": "BLK 704 ANG MO KIO AVENUE 8",
        "sellToAddressLine2": "#01-2559",
        "sellToCity": "",
        "sellToState": "",
        "sellToCountry": "",
        "sellToPostCode": "560704",
        "shipToAddressLine1": "BLK 704 ANG MO KIO AVENUE 8",
        "shipToAddressLine2": "#01-2559",
        "shipToCity": "",
        "shipToState": "",
        "shipToCountry": "",
        "shipToPostCode": "560704"
    }

  • Suggested answer
    Gianfranco C. Profile Picture
    Gianfranco C. 370 on at
    RE: Cannot create Sale Order through API

    hello, try using the API instead of the Odata call.
    Set your url like this:

    pastedimage1683964187610v1.png

    in the company you must use the company id and not its name

    Don't forget to help the community by Verifying the answer and Like it if your question has been answered. It will let others know that the topic has verified answer.

    Thanks & Regards,
    Gian

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!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans