Create a gist now

Instantly share code, notes, and snippets.

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 = "" + 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