我尝试使用MS Cognitive面部API创建人员组,但我不断收到错误消息" {\"错误\":{\"代码\":\" BadArgument \",\"消息\":\"请求正文无效。\"}}&# 34 ;.我知道这是我身体的问题。以下是我的源代码。如果有人能帮我解决这个问题会很高兴。
public async Task<dynamic> CREATEPERSONGROUP()
{
var get = await MakeRequest();
var response = get;
return Json(data: response);
}
static async Task<string> MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key",
subscriptionKey);
var uri = "https://westcentralus.api.cognitive.microsoft.com
/face/v1.0/persongroups/rwtfacesearchgroup1?" + queryString;
HttpResponseMessage response;
// Request body
byte[] byteData = Encoding.UTF8.GetBytes("name: searching");
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new
MediaTypeHeaderValue("application/json");
response = await client.PutAsync(uri, content);
string contentString = await
response.Content.ReadAsStringAsync();
return (contentString);
}
}