最后编辑于2019-11
返回错误:
{"error_code":222200,"error_msg":"request body should be json format","log_id":2555949445892,"timestamp":1533804250,"cached":0,"result":null}
代码如下:
def faceverify(self,file_name):
base64_data=self.base64_coding(file_name)
url='https://aip.baidubce.com/rest/2.0/face/v3/faceverify'+ "?access_token=" + access_token
http = urllib3.PoolManager()
data={
"image": base64_data,
"image_type":"BASE64"
# "face_field":"qualities,faceliveness"
}
headers={
# "Content-Type":"application/x-www-form-urlencoded"
"Content-Type":"application/json"
}
data = json.dumps(data)
# data=urllib.urlencode(data)
r = http.request('POST',url,body=data,headers=headers)
# req = urllib2.Request(url)
# req.add_header('Content-Type','application/json')
# r = urllib2.urlopen(req,data)
# print r.read()
print r.data
我明明都有 data = json.dumps(data)
求助
请登录后评论
TOP
切换版块
这个问题我也遇到了,后来解决了,前端代码:
当时我的错误代码是这样的
let data = {
image: tempImgData,
image_type: 'BASE64',
}
后来在外面加一个中括号变成数组就可以了:
let data = [{
image: tempImgData,
image_type: 'BASE64',
}]
具体原因没搞明白,在这个地方卡住了,和楼上的童鞋一样,设置了headers,也是不行,用了qs.stringify和JSON.stringify都不行,虽然好了但是不太明白,有明白的给指点一下吧
同问222200的错误
js怎么实现
我也遇到了,你们解决了嘛
你们的解决了嘛
我这样写有什么错误,返回的也是"error_code":222200
博主请问,上下两端代码有啥区别 没看出来
解决了 :
很奇怪的是,v3 版本的api 表单是个list,然后json.dumps(),如下: