I am new to C # and also on this site. I am testing the Microsoft API called Face API
, however, I can not do the following program in C #, which is in the following web page .
I created the group, and I have also created three people, and the next step is Add a Person Face , could you please help me with an example of the method.
This is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http.Headers;
using System.Net.Http;
using System.Web;
using Microsoft.ProjectOxford.Face;
using Microsoft.ProjectOxford.Face.Contract;
using System.IO;
namespace Add_person_face
{
class Program
{
static void Main(string[] args)
{
MakeRequest();
Console.WriteLine("Presione enter para salir una vez reciba una respuesta...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var personGroupId = "equipocinco-si";
string personId = "b2d1bdbb-71b5-4ef5-bf4b-44eaed66effd";
string persona = "PersonaPrueba";
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "14ddaee113114f23bf3b541480107a3c");
Stream s = File.OpenRead(@"C:\Users\S\Desktop\prueba.jpg");
string json = "{\"url\":\"" + s + "}";
var uri = "https://westus.api.cognitive.microsoft.com/face/v1.0/persongroups/" + personGroupId + "/persons/" + personId + "/persistedFaces?" + json;
// Request body
// Request parameters
// Request body
//string persistedFaceId = "";
//string json2 = "{\"persistedFaceId\":\"}";
HttpContent content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
}
}
}