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...
Answered

Odata Sales Order Creation - Wrong Zip Code Picked from the Zip Codes table

(0) ShareShare
ReportReport
Posted on by 51

Hi All,

I am creating sales orders in NAV through Odata REST web services, I set "ship_to" details in the JSON of the POST request i.e., City, State, Zip Code and Country. NAV tends to pick up the details which appear 1st on the Zip Codes table based on Zip Code and City. Since same zip code has different city names, I'm facing issue with address mis-match on the sales order and tax calculation.

For instance the order details I set in JSON are as follows:
{

  "Ship_to_City": "Sandstone",
  "Ship_to_County": "MN",
  "Ship_to_Post_Code": "55072",
  "Ship_to_Country_Region_Code": "US"

}

Details about zip code 55072 (from google): 55072, Postal code in Minnesota, Cities: Sandstone, MN, Markville, MN, Cloverton, MN, Duxbury, MN, Kingsdale, MN, Groningen, MN
So same zip code has different city names.

Zip Code Table in NAV: has 2 entries for 55072

Code     City    Country

55072    Markville    US      ----- NAV always picks this details

55072    Sandstone   US    ----- when I try to post with this line details

After creating the sales order, NAV returns the following:
{

  "Ship_to_City": "Markville",
  "Ship_to_County": "MN",
  "Ship_to_Post_Code": "55072",
  "Ship_to_Country_Region_Code": "US"

}

Due to this, the customer order details and what's in NAV do not match up which in-turn causes tax miscalculation in NAV.

From my little understanding of NAV:
1. While creating a new entry in zip codes table, the combination of Zip code and City name is treated as primary/unique key.

2. When I post a sales order, NAV gets all the entries for a zip code and sorts it based on city name to pick the first one from the list.

Please help me resolve the issue.

Thanks in Advance!

Kishore.

I have the same question (0)
  • Kishore22 Profile Picture
    51 on at
    RE: Odata Sales Order Creation - Wrong Zip Code Picked from the Zip Codes table

    Thanks Suresh Kulla, your response definitely helped me.

    My approach:

    1. I just POST the sales order as I used to do it previously.

    2. I compare the Code, City, County and Country in both POST body JSON and NAV response JSON.

    3. If they are different, I do a PUT/PATCH request with correct details.

    And above approach works fine.

    Thanks again,

    Kishore.

  • Verified answer
    Suresh Kulla Profile Picture
    49,396 Super User 2025 Season 2 on at
    RE: Odata Sales Order Creation - Wrong Zip Code Picked from the Zip Codes table

    Try setting the city and county values after you set the post code

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
Sumit Singh Profile Picture

Sumit Singh 2,710

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 2,675 Super User 2025 Season 2

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,203

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans