Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (50.2k points)

I was working on some online assignment, there I need to work on a program that will prompt for a location, contact a web service and recover JSON for the web service and parse that information, and retrieve the first place_id from the JSON. A place ID is an identifier(textual ) that uniquely distinguishes a place within Google Maps. API End Points

To finish this assignment, we should use this API endpoint that has a static subset of the Google Data.

I have worked on this assignment, but the codes are not operating. I am getting JSONDecodeError whenever I execute the program.

import urllib.request, urllib.parse, urllib.error

import json

adr= ''

while True:

    loca= input('Enter Location: ')

    if len(loca)<1:break

    url=adr + urllib.parse.urlencode({"address": loca})

    print('Retrieving', url)


    print('Retrieved', len(data))


    placeid= jsdata['results'][0]['place_id']

    print('The Place ID is: ', placeid)

1 Answer

0 votes
by (108k points)
edited by

It appears that the error is that this requires an extra parameter (Key)

Missing/incorrect key = parameter (it is an easy number to guess) ...

Edit: Check the documentation

Example 1:

Example 2:

For more information regarding the python basics, do refer to the Python certification course that will help you out in a better way.

Related questions

+2 votes
2 answers
0 votes
1 answer
0 votes
1 answer
asked Jul 15, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jul 5, 2019 in Python by Sammy (47.6k points)

Browse Categories