Get HTTP Error code from requests.exceptions.HTTPError
Date : March 29 2020, 07:55 AM
Hope that helps I am catching exceptions like this, , The HTTPError carries the Response object with it: def get_url_fp(image_url, request_kwargs=None):
response = requests.get(some_url, **request_kwargs)
response.raise_for_status()
return response.raw
try:
a = "http://example.com"
fp = get_url_fp(a)
except HTTPError as e:
# Need to check its an 404, 503, 500, 403 etc.
status_code = e.response.status_code
|
400 Bad Request - https://accounts.google.com/o/oauth2/token
Date : March 29 2020, 07:55 AM
this will help I got this working.. i am sharing the code for those who are stuck with this: $.ajax({
dataType: "json",
url:searchurl,
data: {code:code, client_id:'clientid', client_secret:'secret', redirect_uri:'http://localhost:8085/GmailIntegration/getAuthResponse.jsp', grant_type:'authorization_code'},
type:"POST",
contentType:"application/x-www-form-urlencoded; charset=utf-8",
crossDomain:true,
cache : true,
success:function(data) {
alert(data);
},
error: function(jqXHR, exception, errorstr) {
console.log(jqXHR);
alert(errorstr);
}
});
|
Allowing frontend JavaScript POST requests to https://accounts.spotify.com/api/token endpoint
Date : March 29 2020, 07:55 AM
seems to work fine You can find an example of using express to perform the authentication flow with Spotify on https://github.com/spotify/web-api-auth-examples (see the authorization_code approach). You can't get an access token making a client-side request to /api/token. You need to make a request to /authorize, which will redirect to your redirect_uri, which itself will exchange a code with an access token.
|
HTTPError: 429 Client Error: Too Many Requests on IBM Cloudant with python
Tag : python , By : arbeitandy
Date : March 29 2020, 07:55 AM
Any of those help IBM Cloudant is connected to Jupyter notebook. I can work with database which is not very big. But when I want to get a data from the database which has many data, I get this error: , Try querying like this: database1 = client['comfort']
userID= input("what is your user ID?")
selector = {'user_id': {'$eq': userID}}
docs = database1.get_query_result(selector)
for doc in docs:
do stuff...
|
POST https://accounts.spotify.com/api/token 415 Unsupported Media when using fetch
Date : March 29 2020, 07:55 AM
wish of those help I added "Content-type": "application/x-www-form-urlencoded; charset=UTF-8" and encoded my json body and it's all working now
|