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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Add Sales Order via API

(6) ShareShare
ReportReport
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
I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,218 Super User 2026 Season 1 on at
  • Suggested answer
    YUN ZHU Profile Picture
    101,995 Super User 2026 Season 1 on at
    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
  • AC-26091618-0 Profile Picture
    6 on at
    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
  • CU15101010-0 Profile Picture
    2 on at
    Play Block Blast for free online.
  • Suggested answer
    Gerardo Rentería García Profile Picture
    27,087 Most Valuable Professional on at
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,177 Super User 2026 Season 1 on at
    Adding more details
     
     
    ✅ Mark this answer as verified if it helps you.
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    9,123 Super User 2026 Season 1 on at

    Hi,

    The error you're seeing is tied to how the Ship-to Code field behaves in Page 42 (Sales Order) when accessed via OData. The system is enforcing a UI-level expression that checks whether ShippingOptions = Alternate Shipping Address, and if not, it marks Ship-to Code as non-editable — even via API.

    Here’s how to work around it:

    Step 1: Set ShippingOptions First

    • Before assigning Ship_to_Code, ensure that ShippingOptions is explicitly set to "Alternate Shipping Address" (usually value 1).
    • This must be done in the same payload or in a prior PATCH call — otherwise, the page logic will block the field.

    Step 2: Use PATCH Instead of POST for Updates

    • If the order is already created, use a PATCH call to update ShippingOptions and Ship_to_Code together:
      json
      {
        "ShippingOptions": "1",
        "Ship_to_Code": "SA0002"
      }
       
    • ​​​​​​​This ensures the page logic evaluates correctly before applying the Ship-to Code.

    Step 3: Consider Using a Custom API Page

    • Page 42 has UI-bound logic that doesn’t always behave well via OData. If you need full control, create a custom API page that exposes only the fields you need and bypasses UI expressions.
    • This avoids the Editable expression entirely and gives you clean control over shipping fields.

    Step 4: Validate Ship-to Code Exists

    • Make sure SA0002 exists for customer C01891 in the Customer Ship-to Addresses table. If it doesn’t, BC will reject the assignment even if the field is editable.


    Helpful References:
    Create salesOrders – Microsoft Learn
    Deep Insert with Business Central APIs – Kauffmann Blog
    Sales Order Integration via OData – eOne Solutions
    Community Thread – Ship-to Code API Error


    If you find this helpful, feel free to mark this as the suggested or verified answer.

    Cheers
    Jeffrey

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,119 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,522 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,177 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans