web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    Jeffrey Bulanadi Profile Picture
    6,939 on at
    Add Sales Order via API

    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

  • Suggested answer
    Sohail Ahmed Profile Picture
    10,977 Super User 2025 Season 2 on at
    Add Sales Order via API
    Adding more details
     
     
    ✅ Mark this answer as verified if it helps you.
  • Suggested answer
    Gerardo Rentería García Profile Picture
    22,524 Most Valuable Professional on at
    Add Sales Order via API
  • CU15101010-0 Profile Picture
    2 on at
    Add Sales Order via API
    Play Block Blast for free online.
  • AC-26091618-0 Profile Picture
    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
    90,019 Super User 2025 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
    60,622 Super User 2025 Season 2 on at
    Add Sales Order via API

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,725 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,610

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,221

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans