Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Vison API example
public static async Task<HttpResponseMessage> RequestImageAnalisys(byte[] data)
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", ConfigurationManager.AppSettings["VisionAPI"]);
// Request parameters
queryString["visualFeatures"] = "Categories, Tags, Description, Faces, ImageType, Color, Adult";
queryString["details"] = "Celebrities";
queryString["language"] = "en";
var uri = "https://westus.api.cognitive.microsoft.com/vision/v1.0/analyze?" + queryString;
HttpResponseMessage response;
using (var content = new ByteArrayContent(data))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response = await client.PostAsync(uri, content);
}
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment