Skip to main content

Notifications

Business Central forum
Suggested answer

Add Sales Order via API

Posted on by
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
    YUN ZHU Profile Picture
    YUN ZHU 69,116 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,868 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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 228,317 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans