HttpService:GetAsync() works on local server but fails in live server

I am trying to get locations from keywords and the request works fine in studio but not in an actual server.
I’ve tried using User-Agent but it says not allowed to use User-Agent!

Code:

function Http.getRelevantPlaces(keywords: string): {any}
	local url = `https://nominatim.openstreetmap.org/search?q={HttpService:UrlEncode(keywords)}&format=json&limit=10`
	
	local success, data = pcall(HttpService.GetAsync, HttpService, url, true)
	warn(success, data, url)
	data = success and HttpService:JSONDecode(data) or {}
	
	return data
end

Output (URL: https://nominatim.openstreetmap.org/search?q=Roblox&format=json&limit=10):

Real server: Error 403

Normal:

{
                    [1] =  ▼  {
                       ["addresstype"] = "road",
                       ["boundingbox"] =  ▼  {
                          [1] = "37.5408859",
                          [2] = "37.5412940",
                          [3] = "-122.2996601",
                          [4] = "-122.2988741"
                       },
                       ["class"] = "highway",
                       ["display_name"] = "Roblox Way, Hillsdale, San Mateo, San Mateo County, California, 94403, United States",
                       ["importance"] = 0.05339612191958492,
                       ["lat"] = "37.5410899",
                       ["licence"] = "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
                       ["lon"] = "-122.2992671",
                       ["name"] = "Roblox Way",
                       ["osm_id"] = 491031352,
                       ["osm_type"] = "way",
                       ["place_id"] = 298906661,
                       ["place_rank"] = 26,
                       ["type"] = "residential"
                    },
                    [2] =  ▼  {
                       ["addresstype"] = "building",
                       ["boundingbox"] =  ▼  {
                          [1] = "37.5427520",
                          [2] = "37.5438351",
                          [3] = "-122.3020754",
                          [4] = "-122.3007397"
                       },
                       ["class"] = "building",
                       ["display_name"] = "Roblox Corporation Station 1, 2750, South Delaware Street, San Mateo, San Mateo County, California, 94403, United States",
                       ["importance"] = 6.278858625157576e-05,
                       ["lat"] = "37.5433164",
                       ["licence"] = "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
                       ["lon"] = "-122.3014468",
                       ["name"] = "Roblox Corporation Station 1",
                       ["osm_id"] = 1076151388,
                       ["osm_type"] = "way",
                       ["place_id"] = 298906662,
                       ["place_rank"] = 30,
                       ["type"] = "office"
                    },
                    [3] =  ▶ {...},
                    [4] =  ▶ {...},
                    [5] =  ▶ {...}
                 }

I do assume the website I’m using needs some sort of authentication but I’m unsure what exactly.

1 Like

Bump

1 Like

OpenStreetMap is probably rejecting requests coming from Roblox servers?

The only solution to this is setting up your own proxy server that replies with the data it gathers by irself, similar to how services like “RoProxy” work. Here is a guide on how to set up a Proxy for “Roblox.com”, but it probably applies in the same way to “OpenStreetMap.org”.

3 Likes

Okay maybe I need to find another API becuase idk how to do that other then Google App Scripts which would take to long

1 Like

Good luck finding alternatives!

But if you do find yourself coming back to the proxy idea…

The guide I linked is the easiest way to create a custom proxy. It shows you how to make a reusable Module for it, where you’d just have to call:

local http = require(game.ServerStorage.HTTP)
print(http.getasync("https://nominatim.openstreetmap.org/search?q=Roblox&format=json&limit=10"))
2 Likes

Thanks for helping.
I’ve used app scripts before so I know what I’d have to do

1 Like

I was able to find another API after immense searching.

local url = `https://photon.komoot.io/api/?q={HttpService:UrlEncode(keywords)}&limit=10`

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.