Download file from Salesforce using API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
20-07-20 03:05 PM
Hello,
I would like some advice regarding how to download a file from Salesforce to local folder.
I'm using the BP Skill "Salesforce" to obtain the ContentDocumentId.
I use the following "GET" API to retrieve the base-64 from Salesforce
/services/data/v47.0/sobjects/ContentVersion/[Id]/VersionData
I'm stuck with how to convert the response content to a physical file.
I figure I have to use the code stage to convert the data, but I'm not quite sure how to achieve it.
Any help would be highly appreciated.
Best Regards
Met Vonghiran
------------------------------
Met Vonghiran
Consultant
Deloitte
Asia/Tokyo
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
21-07-20 02:20 PM
sample google search - https://bytes.com/topic/visual-basic-net/answers/362824-convert-base64-string-file
------------------------------
Ashish Easow
Senior Consultant - Professional Services
Blueprism
Asia/Kolkata
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
21-07-20 03:15 PM
Dim fs as new fileStream (Filepath, FileMode.CreateNew)
fs.Write(binaryData,0,binarydata.Length)
fs.close
Use this code, Base64Str is your base 64 String, filepath should be entire file path where you want to save file, like c:/temp.pdf or d:/new.txt , i hope you know the extention.
You can put this in a code stage and run it, it works fine. you will have to import Microsoft.VisualBasic name space in object.
------------------------------
Ishan Mahajan
India
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
22-07-20 01:23 AM
Thank you Ashish and Ishan
I tried the code and it was able to create a file. This is really a big progress.
However, I just realize that the result that I got from using REST API was not in base64 format (it was a raw binary).
Based on the discussion in the link below, I have to create a SOAP API request. If I'm able to achieve that then I could combine with the code stage that you provide to get a physical file.
https://stackoverflow.com/questions/60283198/get-base64-data-of-file-from-salesforce
I'm still new to the concept of API and how to use BluePrism to call it.
I will try to use Utility-HTTP to see if I could get the base64 out of Salesforce or not.
Thank you so much
------------------------------
Met Vonghiran
Consultant
Deloitte
Asia/Tokyo
------------------------------
