使用RestSharp从Cloud Sight C#获取图像响应

时间:2015-06-02 21:29:59

标签: c# api restsharp cloudsight

我想调用名为Cloud Sight的API来提供图像识别。

我想得到一个响应,它基本上描述了从API Cloud Sight提供的图像的URL中的图像。

这是我到目前为止的代码

var client = new RestClient ("http://api.cloudsightapi.com/image_request");

var request = new RestRequest("http://cdn.head-fi.org/c/c8/1000x500px-c8c39533_beats-by-dre-studio.jpg", Method.POST);
request.AddHeader ("CloudSight", [API KEY HERE]);

IRestResponse response = client.Execute(request);
var content = response.Content;
Console.WriteLine (content);

我收到错误消息

{“status”:“404”,“error”:“Not Found”}

Cloud Sight的文档对每种语言都不是很有见地,所以我不确定我是否正确调用它,特别是AddHeader部分。

不等待回复也可能是错误。我的代码立即执行,Cloud Sight在其网站上提供的API示例需要10-15秒。

如何让这个API与RestSharp配合使用?

1 个答案:

答案 0 :(得分:1)

只是一个猜测,但你尝试过Method.GET而不是Method.POST吗?通过POST获取图像非常不寻常。