Use API in python get 403


I wan’t get location info from a raspberry pi with LTE module.
So I ask the API but get 403 forbidden. I have an API key and the URL works in a normal desktop browser.

Example URL:*****&mcc=262&mnc=1&lac=4504&cellid=28197377&format=json

python code:
response = urllib.request.urlopen(url)
data_json = json.loads(

File “/usr/lib/python3.9/urllib/”, line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

Why does this happen? Is there maybe a user-agent check? How to solve that?


Well, I answer myself. :wink: Yes, it was the user-agent.