Created
February 27, 2017 18:17
-
-
Save pawlos/514eb66717b76de3116aee78446e779e to your computer and use it in GitHub Desktop.
Vison API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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