Demo 2: C#

An example of how to call the document verification verify endpoint using C#

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

    public class VerifyResult
    {
        public string Result { get; set; }

        // OTHER PROPERTIES LEFT OUT FOR DEMO
    }

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

            var content = new MultipartFormDataContent();

            content.Add(new ByteArrayContent(File.ReadAllBytes("/Id1Image-front.png")), "pages", "id1-front.png");

            content.Add(new ByteArrayContent(File.ReadAllBytes("/Id1Image-back.png")), "pages", "id1-back.png");

            content.Add(new StringContent("Id1"), "DocumentType");

            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/document-verification/verify?api-version=1.1"),
                Content = content
            });

            var verificationResult = JsonConvert.DeserializeObject<VerifyResult>(
                await response.Content.ReadAsStringAsync());

            Console.WriteLine($"Verification result: {verificationResult.Result}");

            Console.ReadLine();
        }
    }