Bilagscan offers multiple ways of uploading vouchers to our system. The quickest and easiest way is via mail upload - this is done by simply sending an email with an attached voucher file to the 'mail_forward_address' of the organization. Although this is very easy to set up we generally do recommend to use our API endpoint when uploading vouchers since it gives you more flexibility by allowing an optional voucher note, user payment type and even a callback url.

We have attached a simple C# example (works with .NET CORE also) that takes a file, converts it to base64 and upload it to a specific organization. Please note that the VoucherRequest class have multiple properties which are all optional (except VoucherData) that allows for easier integration between Bilagscan and your system. For example if you send a Note when uploading the voucher that voucher will have a note property when viewing its data (same with ErpFolderId).

It is also possible to send a callback url with the voucher, this is explained in more detail here:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
internal class Program
    {
        private static void Main(string[] args)
        {
            new Program().UploadVoucher().Wait();
        }

        private readonly string _accessToken = "myAccessToken";

        public async Task UploadVoucher()
        {
            var fileSrc = @"C:\Users\Thorup's Mac\Desktop\48.pdf";

            var fileBytes = Convert.ToBase64String(File.ReadAllBytes(fileSrc));

            var voucherRequest = new VoucherRequest
            {
                VoucherData = fileBytes
            };
            var organizationId = 3435;
            var serializedRequest = JsonConvert.SerializeObject(voucherRequest);

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken);

                var content = new StringContent(serializedRequest, Encoding.UTF8, "application/json");
                var response = await client.PostAsync(
                    $"https://api.bilagscan.dk/v1/organizations/{organizationId}/vouchers", content);
                var res = await response.Content.ReadAsStringAsync();
                Console.WriteLine(res);
            }
        }

        public class VoucherRequest
        {
            [JsonProperty(PropertyName = "voucher_data")]
            public string VoucherData { get; set; }

            [JsonProperty(PropertyName = "callback_url")]
            public string CallbackUrl { get; set; }

            [JsonProperty(PropertyName = "note")]
            public string Note { get; set; }

            [JsonProperty(PropertyName = "erp_project_id")]
            public string ErpFolderId { get; set; }
} }