AnsweredAssumed Answered

How to

Question asked by Ismael Liceras on May 28, 2019
Latest reply on May 28, 2019 by Busby

Hi there,

 

I'm trying to retrieve a PDF report from API, so I basically call  '/api/2.0/fo/report/' with action fetch and a report_id which returns a response with content_type = application/pdf.

That sounds corrent to me.

 

The problem comes when trying to save it to a file.

 

My Python code is like this:

with open('output/TEST.pdf', 'wb') as f:
    f.write(response.text.encode('utf-8'))

I did many tests anyway, with different values in encode, and TEXT.pdf cannot be open as Windows says it is corrupted.

 

Could you please guys give me a hand to get the response in a PDF file?

 

Regards,

Outcomes