将图像上载到OCR时出现401错误Microsoft Vision API

时间:2016-06-08 01:30:23

标签: ios objective-c computer-vision microsoft-cognitive

我正在学习Objective-C,我正在尝试将图片上传到microsoft vision api

我已将这些用作标题

    [request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPMethod:@"POST"];
    [request addValue:@"{*************}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];

我从服务器收到此消息

{ "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }

我尝试重新生成密钥,我很确定我正在使用正确的密钥。

1 个答案:

答案 0 :(得分:1)

您需要删除花括号,特别是:

[request addValue:@"*************" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];