Demo 2: C#

An example of how to call the KYC Check endpoint using C#. The following code can be run as a console app to perform Watchlist checks.

namespace KYCCaller
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net.Http;
    using System.Text;
    using System.Threading.Tasks;
    using Newtonsoft.Json;

    public class Match
    {
        public int BirthDay { get; set; }

        public int BirthMonth { get; set; }

        public int BirthYear { get; set; }

        public string Name { get; set; }
    }

    public class WatchlistCheckResult
    {
        public IEnumerable MatchResults { get; set; }
    }

    public class Results
    {
        public WatchlistCheckResult WatchlistCheckResult { get; set; }
    }

    public class KycCheckResponse
    {
        public Results Results { get; set; }
    }

    public class Data
    {
        public string NameQuery { get; set; }
    }

    public class KycCheckRequest
    {
        public string Bundle { get; set; }

        public Data Data { get; set; }
    }

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

            var kycRequest = new KycCheckRequest
            {
                Bundle = "WatchlistCheck",
                Data = new Data
                {
                    NameQuery = "Robert Mugabe"
                }
            };

            var requestJson = JsonConvert.SerializeObject(kycRequest);

            var response = await client.SendAsync(new HttpRequestMessage
            {
                Method = HttpMethod.Post,
                Headers = { { "Authorization", "Basic -YOUR API KEY-" } },
                RequestUri = new Uri("https://api.w2globaldata.com/kyccheck?api-version=1.0"),
                Content = new StringContent(requestJson, Encoding.UTF8, "application/json")

            });

            if (!response.IsSuccessStatusCode)
            {
                // Handle failed requests
            }

            var kycResponse = JsonConvert.DeserializeObject(
                await response.Content.ReadAsStringAsync());

            Console.WriteLine($"Found {kycResponse.Results.WatchlistCheckResult.MatchResults.Count()} matches");
        }
    }
}