반응형
try:
r = requests.get("https://api.spotify.com/v1/search", params=params, headers=headers)
except:
logging.error(r.text)
sys.exit(1)
r = requests.get("https://api.spotify.com/v1/search", params=params, headers=headers)
if r.status_code != 200:
logging.error(r.text)
if r.status_code == 429:
retry_after = json.loads(r.headers)['Retry-After']
time.sleep(int(retry_after))
r = requests.get("https://api.spotify.com/v1/search", params=params, headers=headers)
## access_token expired
elif r.status_code == 401:
headers = get_headers(client_id, client_secret)
r = requests.get("https://api.spotify.com/v1/search", params=params, headers=headers)
else:
sys.exit(1)
spotify 에러코드
STATUS CODEDESCRIPTION
200 | OK - The request has succeeded. The client can read the result of the request in the body and the headers of the response. |
201 | Created - The request has been fulfilled and resulted in a new resource being created. |
202 | Accepted - The request has been accepted for processing, but the processing has not been completed. |
204 | No Content - The request has succeeded but returns no message body. |
304 | Not Modified. See Conditional requests. |
400 | Bad Request - The request could not be understood by the server due to malformed syntax. The message body will contain more information; see Response Schema. |
401 | Unauthorized - The request requires user authentication or, if the request included authorization credentials, authorization has been refused for those credentials. |
403 | Forbidden - The server understood the request, but is refusing to fulfill it. |
404 | Not Found - The requested resource could not be found. This error can be due to a temporary or permanent condition. |
429 | Too Many Requests - Rate limiting has been applied. |
500 | Internal Server Error. You should never receive this error because our clever coders catch them all … but if you are unlucky enough to get one, please report it to us through a comment at the bottom of this page. |
502 | Bad Gateway - The server was acting as a gateway or proxy and received an invalid response from the upstream server. |
503 | Service Unavailable - The server is currently unable to handle the request due to a temporary condition which will be alleviated after some delay. You can choose to resend the request again. |
반응형
'DATA Science > DataEngineering' 카테고리의 다른 글
쿼리 줄이기 (0) | 2021.06.23 |
---|---|
mysql window cmd에서 실행 및 aws 로 접속 (0) | 2021.06.23 |
spotify api 설정 및 간단한 검색 (0) | 2021.06.22 |
AWS cli 설치 및 설정(profile 설정하여 관리) (0) | 2021.06.22 |
엔드 투 엔드 아키텍처 예시 (0) | 2021.06.21 |
댓글