0

i have created an app with the openstreetmap api and i'm using the OsmBonusPack library when i tried to get location with getFromLocationName() fontion i get a forbiden error

BONUSPACK: Invalid response from server: HTTP/1.1 403 Forbidden

thanks in advance.

scai
  • 20,297
  • 4
  • 56
  • 72
Hakraf
  • 39
  • 1
  • 6
  • Which exact URL does this response come from? – scai Aug 11 '16 at 18:12
  • This URL : http://nominatim.openstreetmap.org/search?format=json&accept-language=en&addressdetails=1&limit=1&q=brazil – Hakraf Aug 11 '16 at 20:51
  • Works without problems here. Maybe you have been blocked. Did you respect [Nominatim's usage policy](https://wiki.openstreetmap.org/wiki/Nominatim#Usage_Policy)? – scai Aug 12 '16 at 06:31
  • How can i identify my app ? – Hakraf Aug 12 '16 at 14:37
  • You mean setting a valid user agent? See https://stackoverflow.com/questions/21217781/changing-user-agent-in-osmdroid – scai Aug 12 '16 at 15:14
  • Ok if i understood i need to add this line : head.setHeader("User-Agent", "OSMDroid"); But where exactly – Hakraf Aug 12 '16 at 19:35
  • According to the link I mentioned you have to modify `MapTileDownloader.loadTile()`. – scai Aug 12 '16 at 21:14

1 Answers1

1

Known issue. Inconsiderate users of osmdroid have failed to set the user agent correctly and as such, have gotten everyone banned from osm's tile servers.

Documented here: https://github.com/osmdroid/osmdroid/issues/366

Put this in your activity before loading the map.

OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID);

spy
  • 3,199
  • 1
  • 18
  • 26