Using RestSharp to get image response from Cloud Sight C#

1.1k Views Asked by At

I want to call an API called Cloud Sight that provides image recognition.

I want to get a response that basically describes the image from a URL of an image provided from the API Cloud Sight.

This is the code that I Have thus far

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);

I get an error that says

{"status":"404","error":"Not Found"}

The documentation for Cloud Sight is not very insightful for each individual language, so I am unsure if I am calling it correctly, particularly, the AddHeader part.

It may also be an error with not waiting for a response. My code executes immediately and the API example that Cloud Sight provides on their website takes 10-15 seconds.

Any ideas for how to go about getting this API working with RestSharp?

1

There are 1 best solutions below

0
On

Just a guess, but have you tried Method.GET instead of Method.POST? It'd be highly unusual to fetch an image via a POST.