Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Add Sales Order via API

Posted on by 6
Hi,
 
I'm reaching out to the community because we have a tough problem.
 
First of all, i'm not a business central developer so i can't edit the code. Our Business Central is onpremises and we have and we have many different environments.
 
I would like to create a sales order via API odata. I've create a endpoint in "Web Service", page 42:
 
 
This is the call I make with POST method:
With this body i can create a order.
{
    "Payment_Terms_Code":  "60DFFM",
    "Sell_to_Customer_No":  "C01891",
    "Document_Type":  "1",
    "Document_Date":  "2024-09-25",
    "Promised_Delivery_Date":  "2024-09-25",
    "Payment_Method_Code":  "RB",
    "Activity_Code":  "1",
    "Posting_Date":  "2024-09-25"
}
 
If I want to add a Alternative Shipping information no.
 
I Tried this body's:
 
Body with POST call:
{
    "Ship_to_Address":  "LOCALITA\u0027 CASE SPARSE 7",
    "Ship_to_County":  "CR",
    "Activity_Code":  "1",
    "Sell_to_Customer_No":  "C01891",
    "ShippingOptions":  "1",
    "Ship_to_Post_Code":  "26020",
    "Ship_to_Country_Region_Code":  "IT",
    "Payment_Method_Code":  "RB",
    "Document_Date":  "2024-09-25",
    "Ship_to_Address_2":  "",
    "Ship_to_Name":  "A.I.A. - SPA ACQUANEGRA CREMONESE CR",
    "Document_Type":  "1",
    "Ship_to_City":  "ACQUANEGRA CREMONESE",
    "Posting_Date":  "2024-09-25",
    "Ship_to_Code":  "SA0002",
    "Promised_Delivery_Date":  "2024-09-25",
    "Payment_Terms_Code":  "60DFFM"
}
 
Body with Patch call:
{
    "ShippingOptions":  "1",
    "Ship_to_Code":  "SA0002"
}
 
In both cases i receive the same error:
{
  • "error":{}
    • "code":"Unknown",
    • "message":"Property "Editable" for Ship-to Code is invalid. Expression: [p42ShipToOptions = p42ShipToOptions::"Alternate Shipping Address"] CorrelationId: ed64282b-1740-4ec1-a406-d1d8b63c2ad7."
}
 
Can you help us?
 
Thanks in advance
Categories:
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 10,067 Most Valuable Professional on at
    Add Sales Order via API
  • CU15101010-0 Profile Picture
    CU15101010-0 on at
    Add Sales Order via API
    Play Block Blast for free online.
  • AC-26091618-0 Profile Picture
    AC-26091618-0 6 on at
    Add Sales Order via API
    Hi,
     
    Thanks for the answers and support and sorry for my ignorance.
     
    The version of business central we are using is version 18 on premises, does this version have the APIs even if it is not the cloud version?
     
    If I try to make an API call example:

    GET https://{businesscentralPrefix}/api/v2.0/companies({id})/salesOrders({id})

    IIS 404 answers me
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 70,243 Super User 2024 Season 2 on at
    Add Sales Order via API
    It looks like you are using Web Service (Odata), not API.
    This is a problem with the ShippingOptions field, which cannot be modified directly.
    Similar to the question below, just insert Ship_to_Code only.
    Dynamics 365 Business Central: How to change the value of “Ship-to” field (ShipToOptions) on Sales Order via AL
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 58,878 Super User 2024 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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,572 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,706 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans