# Cant download a PDF from API

**URL:** <https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819>\
**Category:** Questions about Thunkable X\
**Created:** [March 11, 2021, 5:25pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819 "2021-03-11T17:25:50Z")\
**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 11, 2021, 5:25pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/1 "2021-03-11T17:25:50Z")

</div>

I really hope someone can help. I cant download a pdf from API.  
I get a raw file that looks like this when i get it in the POSTMAN API.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/0/200d31050f9cf4b7ee66eb71e692654faad0a106.png)  
And when I download it as PDF it looks fine. See below PDF.  
Why cant I download it in the app like this and show it in the PDF reader or webviewer.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/c/7c1568f18eff31c58bd7cdfa539c3f114d87467c.png)

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [March 11, 2021, 5:26pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/2 "2021-03-11T17:26:59Z")

</div>

> [@funhall](#):
>
> I get a raw file that looks like this when i get it in the POSTMAN API.

Is this also what it looks like in the PDF Reader or WebViewer in Thunkable?

I’d imagine that Postman just doesn’t render the PDF file correctly.

---

<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 11, 2021, 5:27pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/3 "2021-03-11T17:27:36Z")

</div>

No there is nothing at all

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [March 11, 2021, 5:28pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/4 "2021-03-11T17:28:37Z")

</div>

Any authentication required to connect to the API?

---

<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 11, 2021, 5:30pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/5 "2021-03-11T17:30:00Z")

</div>

Yes and I am sure that is working since I get a lot of other info from the api

---

<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 11, 2021, 5:49pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/6 "2021-03-11T17:49:29Z")

</div>

@domhnallohanlon There’s a much longer topic about this already. Perhaps this can be merged to it?

> [@I need help to download PDF from a link from API](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651):
>
> Can someone please help me with downloading this pdf from the link I use these blocks. Here is the result to the url for the PDF. If someone can help me I can share the project. 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”,“httpSta…

---

<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 11, 2021, 6:11pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/7 "2021-03-11T18:11:45Z")

</div>

@domhnallohanlon Yes sure. Please merged it with the old one. i dont know how to do that.  
I get the status 200 but the response is empty?  
It is very strange???  
Do I have to get the proberty of the response or something like that???

---

<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 11, 2021, 6:13pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/8 "2021-03-11T18:13:51Z")

</div>

Can you send me the `response` you receive from your API call. I can’t reproduce it in my side but if you can provide the `response` as a file or in a sharable link so I can test 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 11, 2021, 6:21pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/9 "2021-03-11T18:21:21Z")

</div>

Sure but not sure how. Because when i download it from Postman i just download it as a normal PDF

---

<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 11, 2021, 6:37pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/10 "2021-03-11T18:37:03Z")

</div>

Was thinking if the Content-Type had anything to do with it???

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/e/ee2bf705ca819227752e291531bcba9124e1e0c2.png)

Becaue in the docs it looks like it

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/5/d5631e0b0dc552d7ea053c525d17d457be0e5321.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 11, 2021, 6:40pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/11 "2021-03-11T18:40:32Z")

</div>

The text file you sent me as PM is actually a PDF file. Just change the extension from .txt to .pdf and you will be able to open it with any PDF viewer.

---

<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 11, 2021, 6:42pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/12 "2021-03-11T18:42:16Z")

</div>

Yes but the problem is that the file i sent to you was saved from the postman api and not in the app. I dont get anything when I download it from the app

---

<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 11, 2021, 6:47pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/13 "2021-03-11T18:47:43Z")

</div>

Part of the problem is that the demo url works perfectly but the url @funhall is using with authentication doesn’t return a valid value (my guess! We don’t know…). So the problem is not with the API and probably not with the JSON parsing either. The problem is that we haven’t seen a valid FULL url including authentication.

> [@I need help to download PDF from a link from API](https://community.thunkable.com/t/i-need-help-to-download-pdf-from-a-link-from-api/1134651/18):
>
> @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 11, 2021, 6:49pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/14 "2021-03-11T18:49:28Z")

</div>

What are you meaning by URL with authentication. Is that not the Tokens that I have in the header???

---

<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 11, 2021, 6:52pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/15 "2021-03-11T18:52:32Z")

</div>

Isn’t the same as this that I dont have in the Postman either??? And still I get the PDF file…  
Maybe I am completly wrong and then I am so sorry.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/3/2371ecbdf328a644dfef76f942f041c92d85082a.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 11, 2021, 7:25pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/16 "2021-03-11T19:25:09Z")

</div>

It might be the same, I don’t know. I’ve never gotten an API call in Thunkable to work with anything more complicated than just including the API key in the url. The good thing about that is you can test it in a browser without Postman or Thunkable. But we couldn’t get to that step. So knowing it works in Postman but not in Thunkable… there’s a large gap there that could be filled by testing in a browser (without either tool).

But I’m not sure how to get there and I’ve been back and forth with you about this so many times in three different topics now that I’m out of suggestions. Maybe someone who has more experience with authenticating API calls in Thunkable will know.

---

<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 11, 2021, 7:38pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/17 "2021-03-11T19:38:28Z")

</div>

The authentication is clearly there in @funhall post number 10.

When you run the URL without authentication you get this

 ![Screenshot_20210311_223704](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/8/e8b89ec25840c5ccebce8a2c7a05679103de3351.jpeg)

Therefore it won’t work without proper keys.

---

<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 11, 2021, 7:40pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/18 "2021-03-11T19:40:44Z")

</div>

Yes I se what you mean. But I just cant see where i miss those keys. Because I can get everything else from the API. I have the two need Tokens also.  
So where is it that they are missing???  
I just cant figure it out…

---

<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 11, 2021, 7:57pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/19 "2021-03-11T19:57:59Z")

</div>

In Postman there is a header tab next to Authorization tab it says in your screen `Headers (10)` can you check it please. Most API keys are placed in the header of the API object structure.

---

<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 11, 2021, 8:02pm UTC](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819/20 "2021-03-11T20:02:20Z")

</div>

like this

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/8/e883f7e4f0eebd15d816157f353daa7636ce8d47.png)

[Next page](https://community.thunkable.com/t/cant-download-a-pdf-from-api/1160819.md?page=2)
