This forum is now read-only. Please use our new forums! Go to forums
banner
Close banner
The code looks fine but does not run???
from urllib2 import urlopen
from json import load, dumps
url = 'http://api.npr.org/query?apiKey='
key = 'API_KEY'
url = url + key
url += '&numResults=1&format=json&id=1007' #1007 is science
url += '&requiredAssets=audio,text,image'
response = urlopen(url)
json_obj = load(response)
for story in json_obj['list']['story']:
print "TITLE: " + story['title']['$text'] + "\n"
I get a error with this message below: Did you create a query string parameter for requiredAssets?
Even though I have created requiredAssets with the appropirate atrributes, it does not run.
Need help
Answer 51d1939f631fe9b11a016b57
-4 votes
Put the ‘A’ in ‘requiredAssets’ (sic) in lowercase. Your final string should be:
url += 'requiredassets=audio,text,image'
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
1 comments
instead of having required assets only in the url definiton. make it an independent variable and concatenate to the url string after.