Need help to download af PDF that is a stream of RAW bytes

Hi All.

I am getting respons from my account API with invoices from my customers. And I need to download the invoices locally or other place. And they are telling me that when i try to get the file i will recieve it as a stream of RAW bytes I need to save as PDF.
Can some one please explaine that in Thunkable language and how can I solve that please…

If the API is returning bytes, what does that data look like? I’m assuming it’s formatted in Base64. If that’s the case, you may need a decoder like this.

Can you post a sample of that data (you’d want to strip out any personal info first…)?

Hi now it have nothing with Base64 to do.
It is a raw file. So the respons I have to save as PDF somehow. Can you help me with that please

I don’t know what a “raw file” means. Can you provide a sample? Without seeing the data, there’s no way I can help you. Maybe someone else is more familiar with that but I learn from seeing something and then trying different approaches based on the data.

1 Like

I think you have to forget about the raw file. I just need to save the pdt I get from the link in the respons from the API.
Does that give any meaning to you?

Nope, sorry. I mean, I understand what you’re saying but I have no way to suggest anything without seeing the actual link/file.

It would be like someone saying “I’m going to receive a gift and I want you to buy a box that fits it perfectly.” How would you know what size box to buy based on only that description? :grimacing:

1 Like

Hi. I cant get the file from the api because I dont know how ot works with the link i get from the API.
But I found the docs here.
https://restdocs.e-conomic.com/#get-invoices-paid
Hope that can specifie it for you more than I can.
Thanks so much for helping me out

Martin

Okay, so I may have misunderstood. You’re at the point where you need to figure out how to GET the information from the API, correct? It’s not that you’ve already gotten the information and just need help saving/converting it.

I may be able to help with that.

This section of the documentation includes the GET command for invoices:

https://restdocs.e-conomic.com/#invoices

It only lists javascript which I’m not all that familiar with. The documentation is pretty limited compared to some APIs I’ve used. There aren’t example of how to create REST calls which is what I typically use and there aren’t examples of the JSON result which is really unfortunate because that’s the main thing I need to know to help you with the next steps. But it’s possible we can still get this to work.

Based on the javascript:

$.ajax({
    url: "https://restapi.e-conomic.com/invoices",
    dataType: "json",
    headers: {
        'X-AppSecretToken': "demo",
        'X-AgreementGrantToken': "demo",
        'Content-Type': "application/json"
    },
    type: "GET"
})
    .always(function (data) {
    $("#output").text(JSON.stringify(data, null, 4));
});

It looks like you’ll need a secret token and grant token. It appears you can use “demo” for both so that’s good.

Edit: Oh! Perfect! They have a demo url:

https://restapi.e-conomic.com/invoices?demo=true

It returns this JSON:

{"drafts":"https://restapi.e-conomic.com/invoices/drafts?demo=true","booked":"https://restapi.e-conomic.com/invoices/booked?demo=true","paid":"https://restapi.e-conomic.com/invoices/paid?demo=true","unpaid":"https://restapi.e-conomic.com/invoices/unpaid?demo=true","overdue":"https://restapi.e-conomic.com/invoices/overdue?demo=true","notDue":"https://restapi.e-conomic.com/invoices/not-due?demo=true","sent":"https://restapi.e-conomic.com/invoices/sent?demo=true","totals":"https://restapi.e-conomic.com/invoices/totals?demo=true","self":"https://restapi.e-conomic.com/invoices?demo=true"}

Which when formatted at https://jsonformatter-online.com looks like this:

The “paid” url (https://restapi.e-conomic.com/invoices/paid?demo=true) generates a long JSON response:

{"collection":[{"bookedInvoiceNumber":42,"date":"2020-04-07","currency":"DKK","exchangeRate":100.000000,"netAmount":0.00,"netAmountInBaseCurrency":0.00,"grossAmount":0.00,"grossAmountInBaseCurrency":0.00,"vatAmount":0.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2020-04-15","paymentTerms":{"paymentTermsNumber":1,"daysOfCredit":8,"name":"Netto 8 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/1?demo=true"},"customer":{"customerNumber":12345678,"self":"https://restapi.e-conomic.com/customers/12345678?demo=true"},"recipient":{"name":"Test Firma A/S","address":"Testvej 4","zip":"7100","city":"Vejle","country":"Danmark","attention":{"customerContactNumber":501,"self":"https://restapi.e-conomic.com/customers/12345678/contacts/501?demo=true"},"vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"notes":{"textLine1":"Booked af Henry - hb@incaptiva.dk"},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/42/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/42/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/42?demo=true"},{"bookedInvoiceNumber":10001,"date":"2011-10-10","currency":"DKK","exchangeRate":100.000000,"netAmount":100000.00,"netAmountInBaseCurrency":100000.00,"grossAmount":125000.00,"grossAmountInBaseCurrency":125000.00,"vatAmount":25000.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2011-11-09","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1000,"self":"https://restapi.e-conomic.com/customers/1000?demo=true"},"recipient":{"name":"Møbelfabrikken A/S","address":"Møtrikvej 1","zip":"2750","city":"Ballerup","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10001/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10001/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10001?demo=true"},{"bookedInvoiceNumber":10002,"date":"2011-10-31","currency":"DKK","exchangeRate":100.000000,"netAmount":50000.00,"netAmountInBaseCurrency":50000.00,"grossAmount":62500.00,"grossAmountInBaseCurrency":62500.00,"vatAmount":12500.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2011-11-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1001,"self":"https://restapi.e-conomic.com/customers/1001?demo=true"},"recipient":{"name":"IT Specialisterne ApS","address":"Idevej 7","zip":"8850","city":"Bjerringbro","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10002/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10002/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10002?demo=true"},{"bookedInvoiceNumber":10003,"date":"2011-11-20","currency":"DKK","exchangeRate":100.000000,"netAmount":150000.00,"netAmountInBaseCurrency":150000.00,"grossAmount":187500.00,"grossAmountInBaseCurrency":187500.00,"vatAmount":37500.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2011-12-20","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1005,"self":"https://restapi.e-conomic.com/customers/1005?demo=true"},"recipient":{"name":"TopTeam","address":"Wildersgade 10B","zip":"1408","city":"København K","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10003/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10003/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10003?demo=true"},{"bookedInvoiceNumber":10004,"date":"2011-11-30","currency":"DKK","exchangeRate":100.000000,"netAmount":120000.00,"netAmountInBaseCurrency":120000.00,"grossAmount":150000.00,"grossAmountInBaseCurrency":150000.00,"vatAmount":30000.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2011-12-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1007,"self":"https://restapi.e-conomic.com/customers/1007?demo=true"},"recipient":{"name":"Andersens Eftf. A/S","address":"Wildersgade 10B","zip":"1408","city":"København K","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10004/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10004/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10004?demo=true"},{"bookedInvoiceNumber":10005,"date":"2011-12-20","currency":"DKK","exchangeRate":100.000000,"netAmount":150000.00,"netAmountInBaseCurrency":150000.00,"grossAmount":187500.00,"grossAmountInBaseCurrency":187500.00,"vatAmount":37500.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-01-19","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1005,"self":"https://restapi.e-conomic.com/customers/1005?demo=true"},"recipient":{"name":"TopTeam","address":"Wildersgade 10B","zip":"1408","city":"København K","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10005/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10005/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10005?demo=true"},{"bookedInvoiceNumber":10006,"date":"2012-02-28","currency":"DKK","exchangeRate":100.000000,"netAmount":160000.00,"netAmountInBaseCurrency":160000.00,"grossAmount":200000.00,"grossAmountInBaseCurrency":200000.00,"vatAmount":40000.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-03-29","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1003,"self":"https://restapi.e-conomic.com/customers/1003?demo=true"},"recipient":{"name":"Storeskolen","address":"Byvej 4","zip":"3450","city":"Allerød","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10006/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10006/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10006?demo=true"},{"bookedInvoiceNumber":10007,"date":"2012-03-31","currency":"DKK","exchangeRate":100.000000,"netAmount":250000.00,"netAmountInBaseCurrency":250000.00,"grossAmount":312500.00,"grossAmountInBaseCurrency":312500.00,"vatAmount":62500.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-04-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1000,"self":"https://restapi.e-conomic.com/customers/1000?demo=true"},"recipient":{"name":"Møbelfabrikken A/S","address":"Møtrikvej 1","zip":"2750","city":"Ballerup","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10007/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10007/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10007?demo=true"},{"bookedInvoiceNumber":10008,"date":"2012-03-31","currency":"DKK","exchangeRate":100.000000,"netAmount":29350.00,"netAmountInBaseCurrency":29350.00,"grossAmount":36687.50,"grossAmountInBaseCurrency":36687.50,"vatAmount":7337.50,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-04-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1004,"self":"https://restapi.e-conomic.com/customers/1004?demo=true"},"recipient":{"name":"Lilleskolen","address":"Gl. Kongevej 121","zip":"2850","city":"Nærum","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10008/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10008/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10008?demo=true"},{"bookedInvoiceNumber":10009,"date":"2012-05-31","currency":"DKK","exchangeRate":100.000000,"netAmount":175000.00,"netAmountInBaseCurrency":175000.00,"grossAmount":218750.00,"grossAmountInBaseCurrency":218750.00,"vatAmount":43750.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-06-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1005,"self":"https://restapi.e-conomic.com/customers/1005?demo=true"},"recipient":{"name":"TopTeam","address":"Wildersgade 10B","zip":"1408","city":"København K","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10009/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10009/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10009?demo=true"},{"bookedInvoiceNumber":10010,"date":"2012-06-30","currency":"DKK","exchangeRate":100.000000,"netAmount":202500.00,"netAmountInBaseCurrency":202500.00,"grossAmount":253125.00,"grossAmountInBaseCurrency":253125.00,"vatAmount":50625.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-07-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1000,"self":"https://restapi.e-conomic.com/customers/1000?demo=true"},"recipient":{"name":"Møbelfabrikken A/S","address":"Møtrikvej 1","zip":"2750","city":"Ballerup","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10010/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10010/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10010?demo=true"},{"bookedInvoiceNumber":10011,"date":"2012-06-30","currency":"DKK","exchangeRate":100.000000,"netAmount":250000.00,"netAmountInBaseCurrency":250000.00,"grossAmount":312500.00,"grossAmountInBaseCurrency":312500.00,"vatAmount":62500.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-07-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1001,"self":"https://restapi.e-conomic.com/customers/1001?demo=true"},"recipient":{"name":"IT Specialisterne ApS","address":"Idevej 7","zip":"8850","city":"Bjerringbro","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10011/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10011/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10011?demo=true"},{"bookedInvoiceNumber":10012,"date":"2012-06-30","currency":"DKK","exchangeRate":100.000000,"netAmount":75000.00,"netAmountInBaseCurrency":75000.00,"grossAmount":93750.00,"grossAmountInBaseCurrency":93750.00,"vatAmount":18750.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-07-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1002,"self":"https://restapi.e-conomic.com/customers/1002?demo=true"},"recipient":{"name":"Ejendomsmæglerne BoBedre","address":"Bymidten 2","zip":"3600","city":"Frederikssund","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10012/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10012/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10012?demo=true"},{"bookedInvoiceNumber":10013,"date":"2012-09-30","currency":"DKK","exchangeRate":100.000000,"netAmount":18000.00,"netAmountInBaseCurrency":18000.00,"grossAmount":22500.00,"grossAmountInBaseCurrency":22500.00,"vatAmount":4500.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-10-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1001,"self":"https://restapi.e-conomic.com/customers/1001?demo=true"},"recipient":{"name":"IT Specialisterne ApS","address":"Idevej 7","zip":"8850","city":"Bjerringbro","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10013/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10013/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10013?demo=true"},{"bookedInvoiceNumber":10014,"date":"2012-09-30","currency":"DKK","exchangeRate":100.000000,"netAmount":125000.00,"netAmountInBaseCurrency":125000.00,"grossAmount":156250.00,"grossAmountInBaseCurrency":156250.00,"vatAmount":31250.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-10-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1002,"self":"https://restapi.e-conomic.com/customers/1002?demo=true"},"recipient":{"name":"Ejendomsmæglerne BoBedre","address":"Bymidten 2","zip":"3600","city":"Frederikssund","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10014/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10014/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10014?demo=true"},{"bookedInvoiceNumber":10015,"date":"2012-11-30","currency":"DKK","exchangeRate":100.000000,"netAmount":60000.00,"netAmountInBaseCurrency":60000.00,"grossAmount":75000.00,"grossAmountInBaseCurrency":75000.00,"vatAmount":15000.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-12-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1005,"self":"https://restapi.e-conomic.com/customers/1005?demo=true"},"recipient":{"name":"TopTeam","address":"Wildersgade 10B","zip":"1408","city":"København K","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10015/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10015/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10015?demo=true"},{"bookedInvoiceNumber":10016,"date":"2012-11-30","currency":"DKK","exchangeRate":100.000000,"netAmount":95000.00,"netAmountInBaseCurrency":95000.00,"grossAmount":118750.00,"grossAmountInBaseCurrency":118750.00,"vatAmount":23750.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2012-12-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1004,"self":"https://restapi.e-conomic.com/customers/1004?demo=true"},"recipient":{"name":"Lilleskolen","address":"Gl. Kongevej 121","zip":"2850","city":"Nærum","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10016/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10016/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10016?demo=true"},{"bookedInvoiceNumber":10017,"date":"2012-12-31","currency":"DKK","exchangeRate":100.000000,"netAmount":155000.00,"netAmountInBaseCurrency":155000.00,"grossAmount":193750.00,"grossAmountInBaseCurrency":193750.00,"vatAmount":38750.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2013-01-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1001,"self":"https://restapi.e-conomic.com/customers/1001?demo=true"},"recipient":{"name":"IT Specialisterne ApS","address":"Idevej 7","zip":"8850","city":"Bjerringbro","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10017/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10017/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10017?demo=true"},{"bookedInvoiceNumber":10018,"date":"2012-12-31","currency":"DKK","exchangeRate":100.000000,"netAmount":35000.00,"netAmountInBaseCurrency":35000.00,"grossAmount":43750.00,"grossAmountInBaseCurrency":43750.00,"vatAmount":8750.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2013-01-30","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1000,"self":"https://restapi.e-conomic.com/customers/1000?demo=true"},"recipient":{"name":"Møbelfabrikken A/S","address":"Møtrikvej 1","zip":"2750","city":"Ballerup","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10018/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10018/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10018?demo=true"},{"bookedInvoiceNumber":10019,"date":"2013-01-31","currency":"DKK","exchangeRate":100.000000,"netAmount":135000.00,"netAmountInBaseCurrency":135000.00,"grossAmount":168750.00,"grossAmountInBaseCurrency":168750.00,"vatAmount":33750.00,"roundingAmount":0.00,"remainder":0.00,"remainderInBaseCurrency":0.00,"dueDate":"2013-03-02","paymentTerms":{"paymentTermsNumber":5,"daysOfCredit":30,"name":"Netto 30 dage","paymentTermsType":"net","self":"https://restapi.e-conomic.com/payment-terms/5?demo=true"},"customer":{"customerNumber":1000,"self":"https://restapi.e-conomic.com/customers/1000?demo=true"},"recipient":{"name":"Møbelfabrikken A/S","address":"Møtrikvej 1","zip":"2750","city":"Ballerup","vatZone":{"name":"Domestic","vatZoneNumber":1,"enabledForCustomer":true,"enabledForSupplier":true,"self":"https://restapi.e-conomic.com/vat-zones/1?demo=true"}},"layout":{"layoutNumber":19,"self":"https://restapi.e-conomic.com/layouts/19?demo=true"},"pdf":{"download":"https://restapi.e-conomic.com/invoices/booked/10019/pdf?demo=true"},"sent":"https://restapi.e-conomic.com/invoices/booked/10019/sent?demo=true","self":"https://restapi.e-conomic.com/invoices/booked/10019?demo=true"}],"pagination":{"maxPageSizeAllowed":1000,"skipPages":0,"pageSize":20,"results":81,"resultsWithoutFilter":81,"firstPage":"https://restapi.e-conomic.com/invoices/paid?demo=true&skippages=0&pagesize=20","nextPage":"https://restapi.e-conomic.com/invoices/paid?demo=true&skippages=1&pagesize=20","lastPage":"https://restapi.e-conomic.com/invoices/paid?demo=true&skippages=4&pagesize=20"},"self":"https://restapi.e-conomic.com/invoices/paid?demo=true"}

Which when formatted looks like this:

And right there at the end is the PDF link (https://restapi.e-conomic.com/invoices/booked/42/pdf?demo=true).

So now it’s just a matter of making a GET command in Thunkable and parsing the JSON data to find that “pdf” property.

You’ll need to get the “download” property of the “pdf” property of the first list item of the “collection” property of the JSON object.

If your head is spinning, welcome to the world of APIs and JSON!!! It took me a good ten hours or so of playing around with this stuff to really start to understand it.

1 Like

Yes i have no problems gerning This info. I just don’t know what to do with it.

There are four main steps to using an API in Thunkable:

  1. Connecting to the API by entering a url in a browser (e.g. Chrome; this step actually isn’t done inside of Thunkable) and viewing JSON data
    https://restapi.e-conomic.com/invoices/paid?demo=true is an example of that but it uses demo data
  2. Connecting to the API url using Thunkable Web API URL and Web API GET blocks and retrieving JSON data
  3. Parsing the JSON data
  4. Deciding what to do with specific JSON data

If you’re able to do #1, it would speed things along if you can PM me with the url you’re using.

Figuring out #2 and #3 are relatively straightfoward and I can provide a screenshot for those. But it won’t actually work without the url from #1.

As far as #4 goes, well, if you have a link to a PDF then you have to decide what you want to do with that link or the file it points to. You can email or text it to someone, you can display it in the app, or you can upload it somewhere.

Here’s a project I made that parses the JSON data from the demo url provided by the company:

https://x.thunkable.com/copy/f7343bf92bcc98848fe698cf6c94a0d3

It attempts to get the “download” property I mentioned above and store that url in an image, a PDF reader, and a label.

Ues that looks right.
I just got the response where the download PDF link is also.
But I am sure you are on the right way. How does the blocks looks for that you mentioned ???

{“collection”:[{“bookedInvoiceNumber”:5,“date”:“2021-02-26”,“currency”:“DKK”,“exchangeRate”:100.000000,“netAmount”:268.80,“netAmountInBaseCurrency”:268.80,“grossAmount”:336.00,“grossAmountInBaseCurrency”:336.00,“vatAmount”:67.20,“roundingAmount”:0.00,“remainder”:0.00,“remainderInBaseCurrency”:0.00,“dueDate”:“2021-02-26”,“paymentTerms”:{“paymentTermsNumber”:3,“daysOfCredit”:0,“name”:“Til omgående betaling”,“paymentTermsType”:“net”,“self”:“https://restapi.e-conomic.com/payment-terms/3"},“customer”:{“customerNumber”:28193617,“self”:“https://restapi.e-conomic.com/customers/28193617”},“recipient”:{“name”:"Martin test”,“address”:“Skoven 5”,“zip”:“8800”,“city”:“Viborg”,“vatZone”:{“name”:“Domestic”,“vatZoneNumber”:1,“enabledForCustomer”:true,“enabledForSupplier”:true,“self”:“https://restapi.e-conomic.com/vat-zones/1"}},“layout”:{“layoutNumber”:18,“self”:“https://restapi.e-conomic.com/layouts/18”},“pdf”:{“download”:“https://restapi.e-conomic.com/invoices/booked/5/pdf”},“sent”:“https://restapi.e-conomic.com/invoices/booked/5/sent”,“self”:“https://restapi.e-conomic.com/invoices/booked/5”},{“bookedInvoiceNumber”:6,“date”:“2021-02-26”,“currency”:“DKK”,“exchangeRate”:100.000000,“netAmount”:38.40,“netAmountInBaseCurrency”:38.40,“grossAmount”:48.00,“grossAmountInBaseCurrency”:48.00,“vatAmount”:9.60,“roundingAmount”:0.00,“remainder”:48.00,“remainderInBaseCurrency”:48.00,“dueDate”:“2021-02-26”,“paymentTerms”:{“paymentTermsNumber”:3,“daysOfCredit”:0,“name”:"Til omgående betaling”,“paymentTermsType”:“net”,“self”:“https://restapi.e-conomic.com/payment-terms/3"},“customer”:{“customerNumber”:28193617,“self”:“https://restapi.e-conomic.com/customers/28193617”},“recipient”:{“name”:"Martin test”,“address”:“Skoven 5”,“zip”:“8800”,“city”:“Viborg”,“vatZone”:{“name”:“Domestic”,“vatZoneNumber”:1,“enabledForCustomer”:true,“enabledForSupplier”:true,“self”:“https://restapi.e-conomic.com/vat-zones/1"}},“layout”:{“layoutNumber”:18,“self”:“https://restapi.e-conomic.com/layouts/18”},“pdf”:{“download”:“https://restapi.e-conomic.com/invoices/booked/6/pdf”},“sent”:“https://restapi.e-conomic.com/invoices/booked/6/sent”,“self”:“https://restapi.e-conomic.com/invoices/booked/6”}],“pagination”:{“maxPageSizeAllowed”:1000,“skipPages”:0,“pageSize”:20,“results”:2,“resultsWithoutFilter”:2,“firstPage”:“https://restapi.e-conomic.com/customers/28193617/invoices/booked?skippages=0&pagesize=20”,“lastPage”:“https://restapi.e-conomic.com/customers/28193617/invoices/booked?skippages=0&pagesize=20”},“self”:"https://restapi.e-conomic.com/customers/28193617/invoices/booked”}

Did you open the project I created? It has the blocks I used. Here you go:

The JSON you posted above is not a full valid response so I can’t do anything with it. It’s probably missing some characters. Hopefully having the blocks in my demo project helps you figure it out. If not, you can either post the url you are using to get the JSON or you can post the full JSON response text.

i will try it tanks you. I will give you a status.
Thanks again

1 Like

hi. Do I have to have the Image also. Does it have a meaning that it is there?
The is crashing when I put the URL into the pdf reader.
I have the right URL in the tes_input 4 field.


And do I have to get the url directly from the API or can I save it and use it in a list later like I have done in this example??

I get This error in the pdf window. I really dont get it. Because i get the URL from the api with the riht token etc. The api block works fine for everything else so it is NOT a demo link??

No, that was just something I decided to test.

I’m sorry, I don’t know much about that. I had never used the PDF reader before today. Are you able to open the url that you get from the JSON and view the PDF outside of Thunkable? The blocks you have are very complicated so I would first make sure the PDF reader works with the basic url. Then try all of those list, etc. blocks.

And yes, you can store the url you get in a variable or list and use it like any other text.

Hi again and thatnks for helping me out.
I now tryed to get the test PDF as you did with succes.
But these blocks is saying that the Booked invoice 3 was not found etc.
Will you please try this again if you still have the prject to se if it works from your side please.

I don’t see those in the link I have from you. Maybe you can resend the link?

Sure.
This is the project you shared with me then
https://x.thunkable.com/copy/1363472ebf257a2c65bedb9f25436965