We have a requirement to get image tags from image.
I am using this API - https://learn.microsoft.com/en-us/rest/api/computervision/3.1/tag-image-in-stream/tag-image-in-stream
I am unclear about the image format that needs to be provided in Request Body of the api, as most of the times, I use to get InvalidImageFormat error.
I am using this code.
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://{test}/vision/v3.1/tag?overload=stream");
client.DefaultRequestHeaders.Add("Accept", "application/octet-stream");
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{apiSubscriptionKey}");
var url = "https://wallpapercave.com/wp/Iw471VJ.jpg";
HttpClient client2 = new HttpClient();
var getStream = client2.GetByteArrayAsync(url);
getStream.Wait();
var imgByteArr = getStream.Result;
string binaryString = string.Join("", imgByteArr.Select(byt => Convert.ToString(byt, 2).PadLeft(8, '0')));
var postTask = client.PostAsJsonAsync<string>(URL, binaryString);
postTask.Wait();
var result = postTask.Result;
Please help me with this.
Thanks.