Conversion of a Blob to PDF file

Hello,

I’m required to fetch some PDF documents from salesforce using API calls.
After calling the API, I’m getting a response shown in below image

I’m not sure how to handle this response in UiPath and save it as a PDF file. Please guide me on how can I convert this response into a PDF file.

Thanks

Hello @vishesh.sharma.adtalem ,
Click the Save response which is top right corner, you may get some data

@vishesh.sharma.adtalem
In UiPath, by using HTTP request activity, can hit the API and save the response in desired folder.
Kindly refer to this thread, you may get some idea.

He’s just showing a debug to show the data he’s receiving, he isn’t UI Automating that screen.

1 Like

Hi @Gokul_Jayakumar,

I tried ‘Save Response’ option of postman and saved the response as a file (response.pdf). I got the actual PDF file.

Now in UiPath, I’ve used HTTP Request activity, which is giving same response in string. How do I save that string as a pdf file?

I’ve tried writing the string response to a file directly using ‘Write Text File’ activity with encoding ‘UTF-8’, ‘ASCII’, ‘UNICODE’, and blank. But it’s giving a blank pdf only.

@postwick I’ve also tried converting response string into Bytes array so that I can write it into a file using System.IO.File.WriteAllBytes. I used 'System.Text.Encoding.<utf8, ascii, unicode etc>.GetBytes(stringResponse), but again I’m getting blank PDF only.

Sorry, I don’t really have an answer - I’ve never done that.

What I’m wondering is why you’re using the Salesforce API instead of navigating into Salesforce and directly downloading the files. That might be more straightforward, although you’re already pretty much there with the API.

You might need to do it with Invoke Code using some of this kind of vb.net code:

Some more info that might be useful.

https://social.msdn.microsoft.com/Forums/en-US/7d4f3b51-b321-495d-8e79-5564b2cd41a1/retrieve-blob-file-from-mysql-and-save-them-to-filesystem?forum=asporacle

@vishesh.sharma.adtalem Try this
In properties, Filename For response add with Extension of .pdf

Environment.CurrentDirectory+"\APIoutput.pdf"        --> PDF file saved in Project loaction

@Gokul_Jayakumar Yeah, that’s working. I’m able to save the response as PDF file. Thank you so much :slight_smile:

@vishesh.sharma.adtalem
Pleasure is mine

Also, you can pass the file path or API as a dynamic
Refer to this

Happy Learning
Happy Automation

Regards,
Gokul Jai

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.