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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to populate custom addresses, ship-to and bill-to fields when posting sales orders via ODataV4

(0) ShareShare
ReportReport
Posted on by

Hi Community members,

In this post I do the following

  1. Create a sales order in BC Web Client
  2. Attempt to create an identical sales order via ODataV4 endpoint using Postman, but fail.
  3. Define the problem and ask for suggestions, so step 2. becomes a success.

1. Creating a sales order in Business Central Web Client

If I use BC Web Client and create a simple sales order like this:

Customer No.: C00010
Customer Name: B2C Account
Contact No.: CT010024
Ship-to: Custom Address
Name (Ship-to): B2C Account
Address (Ship-to): Street 1
Address 2 (Ship-to): 2.3
City (Ship-to): Aarhus
Country (Ship-to): Midtjylland
Post Code(Ship-to): 8000
Country/Region(Ship-to): DK

Then the sales order is saved and valid.

pastedimage1602581917952v2.png

2. Creating a sales order via ODataV4 endpoint using Postman

If I expose page id 42 "Sales Order", copy the ODataV4 URL to Postman and send the following JSON request body:

{
"Document_Type": "Order",
"Sell_to_Customer_No": "C00010",
"Sell_to_Customer_Name": "B2C Account",
"ShippingOptions": "Custom Address",
"Ship_to_Name": "B2C Account",
"Ship_to_Address": "Street 1",
"Ship_to_Address_2": "2.3",
"Ship_to_City": "Aarhus",
"Ship_to_County": "Midtjylland",
"Ship_to_Post_Code": "8000",
"Ship_to_Country_Region_Code": "DK"
}

Then I get this response:

Status: 400 Bad Request

"error": {
"code": "Unknown",
"message": "Property \"Editable\" for Ship-to Name is invalid. Expression: [p42ShipToOptions = p42ShipToOptions::\"Custom Address\"] CorrelationId: bceeb2c8-eff6-421a-b0f8-c61d97a8d4d7."
}

pastedimage1602582115354v3.png

If I omit the Ship_to_Name, then the response is similar in that it is just the next property that becomes a problem.

If I create the sales order first, use the Etag and do a subsequent PATCH to add the custom address in a second go, that also does not work.

3. The issue in a nutshell

I can input custom address and ship-to fields in BC Web Client, but I cannot in ODataV4.

So my question is, how can I populate custom address fields via ODataV4? 

Any suggestions?

Sincerely,

Dan

I have the same question (0)
  • JAngle Profile Picture
    133 on at

    Have you tried omitting the Custom Address line? I recall doing a similar request and just having the shipping address details and the relevant selection is made automatically. Worth a try.

  • Community Member Profile Picture
    on at

    Great suggestion Josh. I had not tried that.

    Unfortunately, it still is not possible.

    pastedimage1602589262278v1.png

    Thanks for your time and for the suggestion.

  • Verified answer
    Ethan-Sorenson Profile Picture
    225 on at

    The standard pages do not expose the ShipToOptions flag that allows you to select a different address.

    I wrote a web service that you can use to update an existing Sales Order with a different ship-to and bill-to address. It only works on Orders that already exist in BC, because I didn't want to have to rewrite all the logic on the page.

    github.com/.../EditShipToBillTo

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Ethan.

    Thank you very much. I am going to give you the credit and say 'Yes' you answered my question.

    Unfortunately I cannot use it, because in my particular case, I cannot use anything custom. My team maintains a codeunit which exposes a SOAP web service and it solves this issue. We can essentially build anything custom. This codeunit is an App on AppSource and we have maintained it since NAV2013. We can and will continue to do this, but we would rather be free of this task. We believe that standard OData endpoints will some day be able to fulfill most of our needs, but alas, not Today. You still answered my question, but in the negative sense. You basically confirm my suspicion that this is a unwanted limitation in BC and possibly a bug.

    I hope that anyone else, facing the same limitation as me and my team, can use your web service.

    Thanks again for taking the time to reply.

    Sincerely,

    Dan

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,577

#2
YUN ZHU Profile Picture

YUN ZHU 888 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 778 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans