Hi Community members,
In this post I do the following
- Create a sales order in BC Web Client
- Attempt to create an identical sales order via ODataV4 endpoint using Postman, but fail.
- 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.

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."
}

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