Luis Masuelli
Luis Masuelli

Reputation: 12343

Passing a list/array as request parameter in GAE

i'd like to know how to pass arrays as REST arguments in a GAE request. My concrete intention is to get an array of ints.

Upvotes: 0

Views: 452

Answers (1)

voscausa
voscausa

Reputation: 11706

You can use json to dump arrays and add the json string to the payload of your post.

Example:

list_1 = [1,2,3,4,5]
list_2 = ['A', 'B', 'C']
data = {'list_1' : list_1, 'list_2' : list_22}
response = urlfetch.fetch(url='http://....', payload=simplejson.dumps(data), method=urlfetch.POST,
                          headers={'Content-Type': 'application/x-www-form-urlencoded'})

Upvotes: 1

Related Questions