同样的请求在postMan 上可以完美执行 图片64位编码没问题。 调用方法是调用的AFN的POST方法
guard let imgData = UIImageJPEGRepresentation(image, 1)?.base64EncodedString() else {
return
}
(imgData as NSString).addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)
let urlString = "https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general"
request(urlString: urlString, parameters: ["image": imgData]) { (result, code) in
print(result)
}
图片是ResponseDetective打印的请求信息,有没有大牛帮忙看看怎么回事?
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
https://ai.baidu.com/forum/topic/show/497218
可以参考【Object-C】直接调用百度AI-API示例
这个错误很明显。告诉你image参数不存在。虽然你写了。但是你拼接的地方不会也会导致这样的返回哦
看你的内容是调用 通用图像分析——通用物体和场景识别 这个接口
接口要求Content-Type为application/x-www-form-urlencoded
那你的参数应该是image=xxxxx 而不是json格式的参数拼接。