我正在尝试使用Bing图像搜索服务,并遵循此处的文档https://docs.microsoft.com/zh-cn/azure/cognitive-services/bing-image-search/quickstarts/csharp
当我运行代码在BingImageSearch方法上用以下命令调试它时-
HttpWebResponse response = (HttpWebResponse)request.GetResponseAsync().Result;
它返回401错误。这是授权错误。我将其用于api调用:
const string uriBase = "https://api.cognitive.microsoft.com/bing/v7.0/images/search";
const string accessKey = "********";
我的accessKey是正确的,已经在azure上进行了检查,但是仍然出现401错误。这是请求的其余代码:
// Construct the URI of the search request
var uriQuery = uriBase + "?q=" + Uri.EscapeDataString("Puppies");
// Perform the Web request and get the response
WebRequest request = HttpWebRequest.Create(uriQuery);
request.Headers["Ocp-Apim-Subscription-Key"] = accessKey;
我在这里想念什么?网址上有东西吗?
弑天下
相关分类