在使用人脸 API V1.0 的人脸检测服务时,我没有遇到任何错误,但也没有结果。我正在研究 c#。API 密钥有效并在其他代码上显示结果。
任何帮助表示赞赏。提前致谢。
Code is as follows:
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "9b0bd0ce75d040769834af2339b93e1d");
// Request parameters
queryString["returnFaceId"] = "true";
queryString["returnFaceLandmarks"] = "false";
queryString["returnFaceAttributes"] = "Age";
//var uri = "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect" + queryString;
var uri = "https://eastasia.api.cognitive.microsoft.com/face/v1.0/detect" + queryString;
HttpResponseMessage response;
// Request body
byte[] byteData = Encoding.UTF8.GetBytes("https://i.kinja-img.com/gawker-media/image/upload/s--0MPvwvU0--/c_scale,f_auto,fl_progressive,q_80,w...");
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
response = await client.PostAsync(uri, content);
}
}
}
}