Postman Example
This describes the process of calling the Document Upload 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/tree/main/REST
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 – Follow these steps to create your own request
1) Set the request Method to ‘POST’
2) Set the URL to the Document Upload endpoint. i.e. https://api.w2globaldata.com/documentupload?api-version=1.0
3) Add an Authorization header to the request with a value of ‘Basic’ and your API key.
4) Set the body of the request to ‘form-data’.
5) Add a data entry to the body with the key as ‘Document’ with the data type set to File.
6) Upload your document to the data entry.
7) Send the request and view the response
C# Example
An example of how to call the upload document endpoint using C#
namespace UploadDocument
{
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class DocumentUploadResponse
{
public long BytesUploaded { get; set; }
public string Reference { get; set; }
public bool DocumentTypeValidationSucceeded { get; set; }
public Guid Id { get; set; }
public string ResolvedDocumentType { get; set; }
}
public class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
var content = new MultipartFormDataContent();
var image = Image.FromFile("C://your-image-file");
using (var memStream = new MemoryStream())
{
image.Save(memStream, ImageFormat.Png);
content.Add(new ByteArrayContent(memStream.ToArray()), "document", "document.png");
}
content.Add(new StringContent("My-Reference-123"), "reference");
var response = await client.SendAsync(new HttpRequestMessage
{
Method = HttpMethod.Post,
Headers = { { "Authorization", "Basic " } },
RequestUri = new Uri("https://api.w2globaldata.com/documentupload?api-version=1.0"),
Content = content
});
if (!response.IsSuccessStatusCode)
{
// Handle failed requests
}
var documentResponse = JsonConvert.DeserializeObject(
await response.Content.ReadAsStringAsync());
Console.WriteLine($"Uploaded document... id: {documentResponse.Id}");
}
}
}