I'm studying a program to get weather forecasts from openweathermap on python.However, a 401 error occurred and we cannot proceed.I saw on the Internet that 401 errors are not allowed, but I have logged in to the site.
I don't understand why I'm logged in but I'm not allowed, but if anyone knows why I get an "unauthorized" error, could you please answer me?
import json, requests, print
APPID='-'# API Key Definitions
url='http://api.openweathermap.org/data/2.5/forecast/daily?q={}&cnt=3&appid={}.format('Akashi-shi,jp',APPID)
response=requests.get(url)
response.raise_for_status()
weather_data=json.loads(response.text)
print.pprint(weather_data)
Resolved. [URL misrepresentation]
There was a difference between the contents of the book and the official documentation.From now on, I will definitely check the official documents.
#×→url='http://api.openweathermap.org/data/2.5/forecast/daily?q={}&cnt=3&appid={}'.format('London', APPID)
url='http://api.openweathermap.org/data/2.5/weather?q={}&appid={}'.format('London', APPID)
According to the error message, a valid APPID is not configured.I'm not familiar with this service, but I think I need to follow the instructions on the link below to create an account and get an APPID.
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
578 Understanding How to Configure Google API Key
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.