【发布时间】:2018-07-01 14:39:17
【问题描述】:
我正在尝试制作一个使用 Bing Visual Search API 的简单工具。我正在关注this guide 来设置 SDK,但无论我将哪个图像传递给该 Search 方法,API 响应似乎都是空的:
var ms = await DownloadStream(img);
var res = await client.Images.VisualSearchMethodAsync(image: ms, knowledgeRequest: (string)null);
我也认为可能是auth不正确造成的,但它似乎返回200,所以我不确定了。
响应正文只显示基本内容和一个空标签:
{"_type": "ImageKnowledge", "instrumentation": {"_type": "ResponseInstrumentation"}, "tags": [{"displayName": "", "actions": [{"actionType": "MoreSizes"}, {"actionType": "ImageById"}]}], "image": {"imageInsightsToken": ""}}
我正在使用 7 天试用订阅,并尝试使用它给我的两个密钥进行身份验证。
我错过了什么吗?
编辑:
这里是下载功能。它从 Discord 链接下载 .png 附件:
static async Task<MemoryStream> DownloadStream(string url)
{
var ms = new MemoryStream();
using (var http = new HttpClient())
using (var res = await http.GetAsync(url))
if (res.IsSuccessStatusCode)
{
await res.Content.CopyToAsync(ms);
ms.Position = 0;
}
return ms;
}
链接示例:https://cdn.discordapp.com/attachments/462686437331042306/462987122203295754/61A88kq3rJL.SY355.jpg
【问题讨论】: