I am trying to send a file to a function on picloud via REST
with poster python library on google app engine (An HTML JPEG image upload). But the function throws this error :
{"error": {"msg": "Function arguments (POST data) are not valid JSON", "code": 446, "data": "{'parameter': u' filename'}", "retry": false}}
I have set the function's output encoding to raw
, also I've followed the docs to detail.
Here are some of the function details.
Function name: detector(name,ifile)
takes two arguments,an image file and its name
Here is a relevant part of the code:
#all needed classes and libraries have been imported,urlfetch, poster,MultipartParam class ect.
#here we go!
params=[]
params.append(MultipartParam("Imagename",filename="anyname.jpg",filetype="application/octet-stream",value=some_file_uploaded_via_html_form))
#http_headers has been defined with appropriate autorization credentials
datagen,headers=multipart.encode(params)
data=str().join(datagen)
result=urlfetch.fetch(url=my_defined_function_url,payload=data,method=urlfetch.POST,headers=http_headers)
print result.content
When I add the following lines,in order to include the real function arguments
params.append(MultipartParam('name',value=filename_variable)
params.append(MultipartParam('ifile',value=some_file_uploaded_via_html_form)
I get the error
{"error": {"msg": " charset is defined multiple times", "code": 445, "retry": false}}
I have also tried wrapping the parameters in a dictionary, rather than separate MultipartParam
instances
Please help.