This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Different results when making a HttpWebRequest and when using Postman

1

Hello, I am trying to get Geo coordinates from a .NET Web App using HttpWebRequest and requesting this link: https://nominatim.openstreetmap.org/search?q=2+$+2A+Cyclone+Street+3995+WONTHAGGI&country=au&format=json&addressdetails=1. In my app, I receive 10 results but none of them are from Australia. If a request the same link from Postman, I receive one result from Australia. Why the difference? Should I set something specific in the web app? Thanks.

asked 20 Nov '19, 11:56

Raluca_A's gravatar image

Raluca_A
26112
accept rate: 0%

Without the relevant code it is going to be very hard to help you with this. Are you escaping the URL properly in your app?

(22 Nov '19, 12:39) SimonPoole ♦
2

Unrelated to your issue: Use &countrycode=au, not &country=au. &country is part of the 'Alternative query string format' (http://nominatim.org/release-docs/latest/api/Search/) and doesn't mix well if &q is already set.

(26 Nov '19, 08:03) mtmail

I changed &country to &countrycode. Thanks.

I can paste here the code, sure, but it's something very simple:

string osmLink = "https://nominatim.openstreetmap.org/search?q=2+$+2A+Cyclone+Street+3995+WONTHAGGI&country=au&format=json&addressdetails=1";

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(osmLink); myRequest.Method = "GET"; myRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";

WebResponse myResponse = myRequest.GetResponse();

string responseText = string.Empty; using (var reader = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8)) { responseText = reader.ReadToEnd().Trim(); }

(02 Dec '19, 11:11) Raluca_A

Source code available on GitHub .