Page tree
Skip to end of metadata
Go to start of metadata

 

The following are basic API operations that you can use in order to integrate your applications with Athento.

 

Previous considerations

$ATHENTO_HOST  is the value for the domain where Athento ECM is deployed.

Authentication and Headers

To authenticate all the services described below it is necessary to set the username and password that will be included by BasicAuthentication in the request headers.

Example using the POSTMAN client for Chrome:

 

In addition, to correctly perform all requests for services, you need to enter the following header:

Content-Type: application/json+nxrequest

 

Example using the POSTMAN client for Chrome:

 

Example of the header for an authenticated request:

Getting the available document types in Athento ECM

 

Available document types
http://$ATHENTO_HOST/nuxeo/api/v1/config/types

 

Athento will return a response as follows:

 

Available document types
{
  "doctypes" : {
    "PaymentOrder" : {
      "parent" : "File",
      "facets" : [ "Downloadable", "Commentable", "Versionable", "Publishable", "HasRelatedText" ],
      "schemas" : [ "administrative", "userFile", "projectFile", "common", "dublincore", "file", "uid", "files", "relatedtext" 
    },
  },
}

Getting the document type for a document

 

Document's doctype
http://$ATHENTO_HOST/nuxeo/restAPI/default/{docId}/export?format=XML

 

You can expect a response similar to the following one:

 

Document's doctype
<document repository="default" id="d6d2a055-6f42-4e6f-ba32-79ab0e24ae86">
	<system>
		<type>Workspace</type>
		<path>AcePros/workspaces/Sample</path>
		<lifecycle-state>project</lifecycle-state>
		<lifecycle-policy>default</lifecycle-policy>
		<facet>SuperSpace</facet>
		<facet>DocumentsSizeStatistics</facet>
		<facet>Folderish</facet>
		<facet>DocumentsCountStatistics</facet>
		<access-control>
			<acl name="inherited">
				<entry principal="tenant-AcePros_tenantAdministrators" permission="Everything" grant="true"/>
				<entry principal="tenant-AcePros_tenantMembers" permission="Read" grant="true"/>
				<entry principal="Everyone" permission="Everything" grant="false"/>
			</acl>
		</access-control>
	</system>...

The document type is located within the <type></type> tags.

Getting the metadata fields for a given document type

This service will return the metadata schema for a given document type.

Document type Metadata
http://$ATHENTO_HOST/nuxeo/api/v1/config/types/{docType}

You will receive a response as follows:

Document type Metadata
{
  "parent" : "File",
  "facets" : [ "Downloadable", "Commentable", "Versionable", "Publishable", "HasRelatedText" ],
  "schemas" : [ {
    "name" : "administrative",
    "@prefix" : "administrative",
    "fields" : {
      "signDate" : "date",
      "concept" : "string",
      "companyNumber" : "string",
      "destinationAccount" : "string",
      "travelPurpose" : "string",
      "transferRequestDate" : "date",
      "company" : "string",
      "sourceAccount" : "string",
      "paymentOrderDate" : "date",
      "travelStartDate" : "date",
      "transferDoneDate" : "date",
      "travelRequestDate" : "date",
      "number" : "string",
      "travelEndDate" : "date",
      "category" : "string",
      "location" : "string",
      "travelName" : "string",
      "expenseDate" : "date",
      "amount" : "string"
    }
  },...

The metadata fields may be part of diferent schema. For an instance, in the previous code you can see the metadata fields for the "PaymentOrder" document type contained within the "filds" schema.

Getting a document

You can get a document by using to different methods:

A) Document ID

Using the Doc ID
http://$ATHENTO_HOST/nuxeo/api/v1/id/{docId}

B) Document Path

Using the Doc Path
http://$ATHENTO_HOST/nuxeo/api/v1/id/{docPath}

Getting the preview image of a given document

 

Document preview
http://$ATHENTO_HOST/nuxeo/restAPI/preview/default/{docId}/files:files-0-file/

 

Deleting a document

 

Delete document
http://$ATHENTO_HOST/nuxeo/restAPI/default/{docId}/deleteDocument

After the call, you will get a response as follows:

Delete response
<document>
	<repository>default<repository/>
	<docRef>Document 4457807c-8d15-4c76-44af-e5676e444ce5ed deleted <docRef>
</document>

Creating a document

The following web service creates a new document with its title.

Document creation
http://$ATHENTO_HOST/nuxeo/restAPI/default/{parentDocId}/createDocument?docType={docType}&dublincore:title={title}

After the call, you will get the following response:

Document create response
<document>
	<repository>default<repository/>
	<docRef>4457807c-8d15-4c76-44af-e5676e444ce5ed<docRef>
	<docTitle>Test</docTitle>
	<docPath>/default-domain/Userworkspaces/user1/Test</docPath>
</document>

 

Updating a document

 

Document update
PUT /nuxeo/site/api/v1/id/{docId}
{
    "entity-type": "document",
    "repository": "default",
    "uid": "37b1502b-26ff-430f-9f20-4bd0d803191e",
    "properties": {
        "dc:title": "The new title",
        "dc:description": "Document updated via REST API"
        "common:icon": "/icons/file.gif",
        "common:icon-expanded": null,
        "common:size": null
    }
}

 

Making queries

 

Queries
http://$ATHENTO_HOST/nuxeo/api/v1/query/?query={queryNXQL}

E.g:

Queries using the API
http://$ATHENTO_HOST/nuxeo/api/v1/query/?query=SELECT * FROM Document WHERE dc:title='ATHENTO'

Using a client like POSTMAN, the previous call would return a response similar to the following one:

Respuesta a una llamada con una query
{
    "entity-type": "documents",
    "isPaginable": true,
    "resultsCount": 2,
    "pageSize": 0,
    "maxPageSize": 0,
    "currentPageSize": 2,
    "currentPageIndex": 0,
    "numberOfPages": 1,
    "isPreviousPageAvailable": false,
    "isNextPageAvailable": false,
    "isLastPageAvailable": false,
    "isSortable": true,
    "hasError": false,
    "errorMessage": null,
    "totalSize": 2,
    "pageIndex": 0,
    "pageCount": 1,
    "entries": [
        {
            "entity-type": "document",
            "repository": "default",
            "uid": "9fb66cdb-2e17-4b1a-bc07-6fa04235047d",
            "path": "/Athento/workspaces/Administración/8. Documentación Yerbabu/MARCA/ATHENTO",
            "type": "Folder",
            "state": "project",
            "parentRef": "c141f110-32da-452c-96c3-aae8aeb9a7f7",
            "versionLabel": "",
            "isCheckedOut": true,
            "title": "ATHENTO",
            "lastModified": "2015-09-16T15:52:42.86Z",
            "facets": [
                "DocumentsSizeStatistics",
                "Folderish",
                "DocumentsCountStatistics"
            ],
            "changeToken": "1442418762861",
            "contextParameters": {
                "documentURL": "/nuxeo/nxdoc/default/9fb66cdb-2e17-4b1a-bc07-6fa04235047d/view_documents"
            }
        },
        {
            "entity-type": "document",
            "repository": "default",
            "uid": "92379199-befe-4430-a7ba-401282656987",
            "path": "/InvoiceDemo/workspaces/PROYECTOS/ATHENTO/ATHENTO",
            "type": "Workspace",
            "state": "project",
            "parentRef": "0f6c49df-186d-4ae3-8486-3a72da40dd44",
            "versionLabel": "",
            "isCheckedOut": true,
            "title": "ATHENTO",
            "lastModified": "2016-03-02T15:42:25.75Z",
            "facets": [
                "SuperSpace",
                "DocumentsSizeStatistics",
                "Folderish",
                "DocumentsCountStatistics"
            ],
            "changeToken": "1456933345758",
            "contextParameters": {
                "documentURL": "/nuxeo/nxdoc/default/92379199-befe-4430-a7ba-401282656987/view_documents"
            }
        }
    ]
}

As you can see, Athento has found 2 documents which title is "ATHENTO". The call response has returned the properties for both documents.

 

More operations

Athento API Guide

For more information download the Athento API Guide available from:

http://go.athento.com/athento-ecm-api-guide

 

  • No labels