API Operations

Documentation for documents

index

Overview

Allows to retrieve a paginated list of the documents visible to the user belonging to an entity.

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.[format]
http method
GET

format must be either json or xml

Required Parameters

entity_id
unique identifier of the entity whom documents are required

Optional Parameters

page
the results page number required

Response

Response is a list of all the documents visible by the user within this entity. Each entry has the following attributes:

id
unique identifier of this entity
file_name
name of the file

Addictionally to the document headers list, the response will contain the following attributes:

page
The actual page displayed
total
The total number of documents found

This is a sample response in JSON format:

{
  "page":"1",
  "total":12,
  "documents":[
    {"id":272,"file_name":"cedolino_cf1.pdf"},
    {"id":273,"file_name":"cedolino_cf2.pdf"},
    {"id":274,"file_name":"cedolino_cf3.pdf"},
    {"id":275,"file_name":"cedolino_cf4.pdf"},
    {"id":276,"file_name":"cedolino_cf1.pdf"},
    {"id":277,"file_name":"cedolino_cf2.pdf"},
    {"id":278,"file_name":"cedolino_cf3.pdf"},
    {"id":279,"file_name":"cedolino_cf4.pdf"},
    {"id":284,"file_name":"cedolino_cf1.pdf"},
    {"id":285,"file_name":"cedolino_cf2.pdf"}
  ]
}
        

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.json -G -d 'entity_id=<entity_id>'

Ruby (with rest_client)

require 'rest_client'
RestClient::Request.new(:method => "get", :url => 'https://www.myo.io/api/v1/documents.json', :headers => { :accept => :json, :content_type => :json, :'Authorization' => "Token token=<auth_token>"}, :payload => {:entity_id => <entity_id>}).execute