Skip to content

Documentation for retrieving a Document is in error #301

Description

@tfuda

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions