API Operations

Documentation for documents

download

Overview

Allows to download a single document accessible by the user.

As all others, this method requires authentication. To understand how to retrieve the authentication token, refer to the Login documentation page.

Request

endpoint
/api/v1/documents/[id]/download
http method
GET

id is the ID obtained with the index api call.

Required Parameters

entity_id
unique identifier of the entity whom documents are required

Optional Parameters

None

Response

Response is the raw binary data of the document.

Examples

In each sample below, you have to substitute values between angular brackets (< and >) with the correct input data.

cUrl

curl -H "Authorization: Token token=<auth_token>" https://www.myo.io/api/v1/documents/<id>/download  -G -d 'entity_id=<entity_id>' > my_document.pdf

Ruby (with rest_client)

require 'rest_client'
response = RestClient::Request.new(:method => "get", :url => 'https://www.myo.io/api/v1/documents/<id>/download',
                                   :headers => { :accept => :json, :content_type => :json,
                                                 :'Authorization' => "Token token=<auth_token>" },
                                   :payload => {:entity_id => <entity_id>}).execute
File.open("document.pdf", "wb") {|file| file << response }