-
-
Notifications
You must be signed in to change notification settings - Fork 363
Open
Description
I tried following the example here: https://github.com/ejholmes/restforce#documents to download the body of a Document and save it to a file. This didn't work for me. Examination of document.Body shows that it contains a URL, like this: /services/data/v35.0/sobjects/Document/0155C00000053lWQAQ/Body for retrieving the body. To correctly retrieve the document body you must do the following:
document = client.query("SELECT Id, Name, Body FROM Document WHERE FolderId = '#{folder.Id}').first
# Get the resource at the URL returned as "Body". This returns a Faraday::Response object
resp = ptech_client.get(document.Body)
File.open(document.Name, 'wb') { |f| f.write(resp.body) }
Metadata
Metadata
Assignees
Labels
No labels