How Can We Help?

Facial Comparison Api via Postman or C#

< All Topics

Postman Example

This describes the process of calling the Facial Comparison Compare endpoint using Postman

Postman is a free app that allows you to perform HTTP requests. You can download it from the Postman website here.

Option 1 – Download and import our example collection

We have set up an example Postman collection that contains example requests that you can import: https://github.com/W2-Global-Data/Api-Samples/blob/main/REST/w2-apipostman_collection.json.

All you will need to do is insert your W2 provided API key into the Authorization header of any request in the collection and it should work.

Option 2 – Setup your own

1. Set the request method to Post

2. Set the URL to the verify endpoint: https://api.w2globaldata.com/facial-comparison/compare?api-version=1.1

3. Add an Authentication header to the request with the schema Basic and the value set to your Api Key.

4. Set the body of the request to ‘form-data’

5. Add the request values to the body following the details here

6. Send the request and view the response.

C# Example

An example of how to call the facial comparison compare endpoint using C#

using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;

public class ComparisonResult
{
    public bool IsMatch { get; set; }

    public int Confidence { get; set; }
}

public class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();

        var content = new MultipartFormDataContent();

        content.Add(new ByteArrayContent(File.ReadAllBytes("/face1.png")), "Current", "current.png");

        content.Add(new ByteArrayContent(File.ReadAllBytes("/face2.png")), "Comparison", "comparison.png");

        content.Add(new StringContent("123"), "ClientReference");

        var response = await client.SendAsync(new HttpRequestMessage
        {
            Method = HttpMethod.Post,
            Headers = { { "Authorization", "Basic YourApiKey" } },
            RequestUri = new Uri("https://api.w2globaldata.com/facial-comparison/compare?api-version=1.1"),
            Content = content
        });

        var comparisonResult = JsonConvert.DeserializeObject<ComparisonResult>(
            await response.Content.ReadAsStringAsync());

        Console.WriteLine($"Comparison result: {comparisonResult.IsMatch}");

        Console.ReadLine();
    }
}
Table of Contents