Reputation: 9820
I'm accessing some data via an API.
The following is my code snippet:
url = self.base_url + specific_url + "?q=" + str(query) + "&" + "filters=[[%22category_id%22,[" + category_id + "]]]" + "&start=" + start + "&sortby=[[%22mpn%22, %22asc%22]]" + "&limit=" + limit + "&apikey=" + self.api_key
response_json = self.web_fetch(url)
return simplejson.loads(urllib.unquote(response_json))
When I go to the URL directly, I can see the data fine. But in my code 'm getting the following error:
No JSON object could be decoded
I started getting this error when I added &sortby=[[%22mpn%22, %22asc%22]]
to the url but I am able to navigate to the page fine in my browser so not sure if that's causing the problem or not.
What would cause this error and what are things I can try to fix it?
Upvotes: 0
Views: 6063
Reputation: 375484
"No JSON object could be decoded" usually means your JSON is an empty string. Print the value of response_json
to see it. Remember the first rule of debugging: When in Doubt, Print More Out.
Upvotes: 1