# I need help to download PDF from a link from API

**URL:** https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651
**Category:** Questions about Thunkable X
**Created:** [March 1, 2021, 3:17pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651 "2021-03-01T15:17:55Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 3:17pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/1 "2021-03-01T15:17:55Z")

</div>

Can someone please help me with downloading this pdf from the link  
I use these blocks.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/f/afa942d3718c4b265dbae6b41fcad2687d2ec95e.png)  
Here is the result to the url for the PDF.  
If someone can help me I can share the project.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/f/ef086003c4d56c4a6cc3e493c3caaa0edcdadf14.png)  
But nothing shows in the PDF reader than this message  
{“message”:“Unauthorized access (Unauthorized).”,“developerHint”:“Please take a look at [https://restapi.e-conomic.com](https://restapi.e-conomic.com/?fbclid=IwAR2Z-OTf1DX67doee68oIMWUkkB1CWzcDOEkWfG80dLcfAUZPYoDUORpH_I) and follow the links to help on authorization, or use the word demo for both tokens.”,“logId”:“6293573ae67ad891-CPH”,“httpStatusCode”:401,“demoLink”:“[https://restapi.e-conomic.com/invoices/drafts/16/pdf?demo=true",“logTime”:"2021-03-01T16:15:26](https://restapi.e-conomic.com/invoices/drafts/16/pdf?demo=true%22%2C%22logTime%22%3A%222021-03-01T16%3A15%3A26&fbclid=IwAR0aHHZMu83ie9y1Ai7Z5sZ3mHnCheWmuP-ZwosK0OnkKbYhbYCBlqK9b98)”}

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 1, 2021, 4:45pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/2 "2021-03-01T16:45:06Z")

</div>

If you have the URL of the PDF file then use the web viewer to download it locally.

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 5:01pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/3 "2021-03-01T17:01:00Z")

</div>

the app crashes everytime.  
Shouldn´t be like this

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/6/f669f78ae410d5aed9222a9021b19158ed101196.png)  
The address is the right one  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/0/c0d9ddeaa5e04a9b3d347fe767a8fed404969965.png)

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 1, 2021, 5:12pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/4 "2021-03-01T17:12:29Z")

</div>

Can you try this URL in your normal browser and make sure that it works without API key or another form of authentication?

It looks to me that it requires a kind of permission or authentication to access the file.

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 5:15pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/5 "2021-03-01T17:15:06Z")

</div>

Yes i dont understand it as well. Because it must need something otherways anyone can get this invoice.  
So I get the file from the api to download the support says.  
Here is the link to the api docs. Hope you can help me.  
[https://restdocs.e-conomic.com/](https://restdocs.e-conomic.com/)  
Or tell me what you need??

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 1, 2021, 5:29pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/6 "2021-03-01T17:29:11Z")

</div>

The documentation does not show any download option in the draft invoices schema.

Also, going back to the URL you provided in the screen it only has folders but no file name.

Can you check again?

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 5:32pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/7 "2021-03-01T17:32:08Z")

</div>

@muneer  
Thanks for your answer.  
Not sure on what to check. But insn´t this docs

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/7/278cad6fa58f81c2d80ee1ddb6263e7603a4bd45.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/5/25aa80470f36afcd499130929e98486d6c8d6050.png)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 1, 2021, 5:47pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/8 "2021-03-01T17:47:02Z")

</div>

This is an extension of [this topic](https://community.thunkable.com/t/need-help-to-download-af-pdf-that-is-a-stream-of-raw-bytes/1125447/10).

I’ve tried a bunch of times to help and we just haven’t gotten very far.

I did create a demo project that works to Get the pdf url from the API and display it in a PDF Reader:

> [@Need help to download af PDF that is a stream of RAW bytes](https://community.thunkable.com/t/need-help-to-download-af-pdf-that-is-a-stream-of-raw-bytes/1125447/11):
>
> 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](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.

In case that’s helpful for @muneer or anyone else who has an idea about this.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 1, 2021, 5:48pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/9 "2021-03-01T17:48:52Z")

</div>

@tatiang  
Can you guide me where to get the url for the pdf file? It will save me a lot of time finding it.

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 5:49pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/10 "2021-03-01T17:49:06Z")

</div>

thanks @tatiang  
I am very frustrated over this. it is almost the last thing i need in the app to finish…

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 5:50pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/11 "2021-03-01T17:50:10Z")

</div>

send you a pm

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 1, 2021, 5:54pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/12 "2021-03-01T17:54:09Z")

</div>

Thank you @funhall , I need the url in the JSON response. Where is it?

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 5:55pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/13 "2021-03-01T17:55:54Z")

</div>

Sorry but not sure what you mean.  
This i send in the request to the api [https://restapi.e-conomic.com/invoices/drafts/16](https://restapi.e-conomic.com/invoices/drafts/16)  
And the I get the respons url from the api. that is in the text field.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 1, 2021, 5:58pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/14 "2021-03-01T17:58:17Z")

</div>

Where is the response **url** that has the pdf filename?

That is what I’m asking for.

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 6:03pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/15 "2021-03-01T18:03:57Z")

</div>

This is a little imbarrising. Because I dont understand what you mean.  
I send the request “[https://restapi.e-conomic.com/invoices/drafts/16](https://restapi.e-conomic.com/invoices/drafts/16)” to the API  
and I get a lot in the response. Inside the response I take out the URL.  
Is that what you ask for. So sorry bare over with me please…

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/6/2674770b3baf90272d3ce6af547e93769fbb04e6.png)

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 1, 2021, 6:23pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/16 "2021-03-01T18:23:56Z")

</div>

I read more in the docs and I think the pdf file is saved as a Base64 encoded which means you need two external libraries to solve the issue. One to decide the Base64 stream into the normal file string and then you need another external library to save the stream as a file.

This is my thoughts.

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 6:31pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/17 "2021-03-01T18:31:23Z")

</div>

The support is writting as follow in danish. I translate below…  
Det er en PDF fil du modtager, men du modtager ikke selve filen men alle data som skaber denne PDF.  
Så når du laver et kald til /pdf så modtager du alle data som skal bruges for at kunne generere en PDF.  
Det er ikke encoded i Base64 eller lign. Det er den fulde data streng som er PDF filen.  
Best regards / Med venlig hilsen  
Thomas Gutfelt Andreasen  
API Support  
Visma e-conomic  
Keep up with us on twitter: @economicAPI

It is a PDF file you recieve. But you dont recieve the file itself but all the data that create this pdf. So when you make a call to/pdf you recieve all data to use for generating the pdf.  
It is not encoded in Base64or something like it. It is the full data string for the PDF file.  
So @muneer hope you are getting something out of this…

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 1, 2021, 6:49pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/18 "2021-03-01T18:49:15Z")

</div>

@muneer I was able to display the “demo” pdf file in the PDF Reader component without doing any conversion. Just straight from the “download” property into that component. But I couldn’t get it to work with @funhall’s authentication and specific API URLs.

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 1, 2021, 6:51pm UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/19 "2021-03-01T18:51:10Z")

</div>

i found aut there there was 2 empty spaces in the start of the URL in the project. Please try and check that @tatiang

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [March 3, 2021, 11:47am UTC](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/20 "2021-03-03T11:47:14Z")

</div>

This is the reply that comes from the API response text

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/6/5601db6d44a6bdcdb3b8ffc3534660fe8c890565.png)  
Are anyon reconciling this?? And know how to make a PDF out of it.

[Next page](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651.md?page=2)
