Hi all,
I have a function as below. This is called as part of API function
rather than from the browser.
def assign():
print request.vars.fields
if request.vars.fields:
case_values=json.loads(request.vars.fields)
ret_dict=api.assign_case(db,case_values)
else:
ret_dict={'id': 1, 'msg': 'No parameters received'}
return json.dumps(ret_dict)
When I invoke this via,
curl -u [email protected]:web2py http://localhost:8000/init/api/assign/
-d fields='{"id":16,"assign_to":"[email protected]"}'
I do get request.vars.fields properly and the function executes as
desired. However when I try the same via a python script like the
below:
data = {
'fields': {'case_id': 16, 'assign_to': '[email protected]'}
}
data = urllib.urlencode(data)
response = urllib2.urlopen(request,data).read()
There is no input parameter (fields). When I examine the
request.vars.fields, it shows like the below:
<Storage {'\r\nfields': "{'case_id': 16, 'assign_to':
'[email protected]'%"}>
There are \r\n at the begining and % at the end. Is there a reason for
this? How can I test my function using python script (ie achieve the
same result as curl).
Hope my question is not too confusing.
Thank you,
Joseph
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---