I need help to download PDF from a link from API

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 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”}

1 Like

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

the app crashes everytime.
Shouldn´t be like this


The address is the right one
image

1 Like

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.

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/
Or tell me what you need??

1 Like

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?

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


This is an extension of this topic.

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:

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

1 Like

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

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

send you a pm

1 Like

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

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

1 Like

Where is the response url that has the pdf filename?

That is what I’m asking for.

This is a little imbarrising. Because I dont understand what you mean.
I send the request “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

1 Like

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.

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…

1 Like

@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.

1 Like

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

1 Like

This is the reply that comes from the API response text


Are anyon reconciling this?? And know how to make a PDF out of it.

1 Like