Wednesday, 15 June 2011

Google Maps Engine API Client Library for Python to create a table asset -



Google Maps Engine API Client Library for Python to create a table asset -

i'm trying utilize google maps engine api client library python create table object using next code:

service = build('mapsengine', 'v1', developerkey=api_key, http=http) table = service.tables() request = table.create(body = body) response = request.execute()

where body following:

{ "projectid": "deletedprojectid", "name": "turf zones of uppsala ", "description": "table contain zones plot", "tags": [ "turf", "turfing", "uppsala" ], "schema": { "columns": [ { "name": "datecreated", "type": "points" }, { "name": "latitude", "type": "points" }, { "name": "longitude", "type": "points" }, { "name": "name", "type": "points" } ] } }

however, error:

--------------------------------------------------------------------------- httperror traceback (most recent phone call last) <ipython-input-76-698f94a34d91> in <module>() ----> 1 response = request.execute() c:\users\user\appdata\local\enthought\canopy32\user\lib\site-packages\oauth2client\util.pyc in positional_wrapper(*args, **kwargs) 130 else: # ignore 131 pass --> 132 homecoming wrapped(*args, **kwargs) 133 homecoming positional_wrapper 134 c:\users\user\appdata\local\enthought\canopy32\user\lib\site-packages\apiclient\http.pyc in execute(self, http, num_retries) 721 callback(resp) 722 if resp.status >= 300: --> 723 raise httperror(resp, content, uri=self.uri) 724 homecoming self.postproc(resp, content) 725 httperror: <httperror 400 when requesting https://www.googleapis.com/mapsengine/v1/tables?alt=json&key=[deleted] returned "a value required.">

i've tried using body = json.dumps(body) still same error. argument .create() takes in body (docs) , based content of body google maps engine tutorial. on google developers console can see i've making requests project (although they've resulted in errors). explain i've done wrong?

i had same problem, in fact how came across question. yes, body looks fine, @ first sight:

body = { "projectid" : "xxx", "name": "api test 2", "layertype": "image" } config = json.dumps(body) print type(config)

spoiler: string!

solution:

body = json.loads(body), create dictionary or pass body straight create method, making sure proper dictionary

one more thing: seems missing mandatory parameter: layertype. check documentation for create method. guess vector in case.

python google-maps google-app-engine python-2.7

No comments:

Post a Comment