ios 调用API 报error216101
hufeng7571326 发布于2018-04 浏览:1500 回复:3
0
收藏
同样的请求在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
个赞
共3条回复 最后由用户已被禁言回复于2018-04
#4用户已被禁言回复于2018-04
#3 用户已被禁言回复
可以参考【Object-C】直接调用百度AI-API示例 

https://ai.baidu.com/forum/topic/show/497218

1
#2用户已被禁言回复于2018-04

这个错误很明显。告诉你image参数不存在。虽然你写了。但是你拼接的地方不会也会导致这样的返回哦

看你的内容是调用 通用图像分析——通用物体和场景识别 这个接口

接口要求Content-Type为application/x-www-form-urlencoded 

那你的参数应该是image=xxxxx  而不是json格式的参数拼接。

1
TOP
切换版块