Skip to content Skip to sidebar Skip to footer

Rest Api for File Upload in Alfresco

The Alfresco ReST API version 1.0 is a consummate application interface that gives you access to all the features of the Alfresco Repository. When edifice remote extensions the Alfresco Residue API is the preferred interface.

The endpoint to access the API has the following format:

dev-api-by-language-alf-rest-intro-1

If you are accessing a local Repository the endpoint URL volition most likely look like follows for a standard Repository installation: https://localhost:8080/alfresco/api/-default-/public/alfresco/versions/i/...

The tenant part will always be -default-, unless you are running a multi-tenant Alfresco solution where you lot would specify what tenant you desire to operate against.

The telescopic is important and it denotes the accessibility of the API, public means it is allowed to use and private means that the API is for internal Alfresco use merely (can change at any fourth dimension). You can add your own scope, such as extension, for your own APIs. The Alfresco Residuum API actually contains a number of APIs and the Core API is denoted past the /alfresco path. You also have the Search, Workflow, Discovery, and Hallmark APIs.

To work with an object in the Repository, such every bit a folder or file node, you lot will append to this URL as follows:

dev-api-by-language-alf-rest-intro-2

An object in the Repository is referred to as an Entity. Which specific example of an entity blazon you are working with is specified equally part of the URL path (i.e. {id}). There can be Relationships betwixt Entities and Operations applied to Entities, which are also specified as part of the URL (i.due east. children, copy).

This department provides information about Alfresco ReST API version i.0 and how to use information technology.

To become started with the API follow these steps:

  1. Read things to know earlier y'all beginning
  2. Install the Residuum API Explorer
  3. Install a tool for making API calls
  4. Install a tool to format JSON responses
  5. Authenticate with the Repository to get a token
  6. Get Repository Info to see what is supported - which uses and tests the auth token

Things to know before you beginning

The Alfresco Rest API endpoints share many features, such as the format for collection responses, how to sort and order responses, how to limit results, how to request optional information, etc.

So it makes sense to know about these features before you kickoff using the API, equally sometimes documentation might non cover all these mutual features, and you would then have to resort to the API Explorer reference.

The API Explorer is your source of truth

The reference documentation for the Alfresco Residue API is available in what is referred to every bit the API Explorer awarding. This application is available for each version of ACS.

If you are confused about what API endpoints that are supported for a specific version of ACS, so install the associated API Explorer and check if the API endpoint is available. If yous are wondering almost specific API endpoint details, and you cannot find any data about it anywhere, consult the API Explorer.

You can find more data near the API Explorer on this page, which also has data on how to install information technology for your specific version of ACS.

If you want to know what the API Explorer looks like correct now, then accept a expect at the online version at https://api-explorer.alfresco.com/api-explorer (annotation that this API Explorer e'er shows the API for the latest version of ACS).

Finding out if an API endpoint is supported in a specific ACS version

The majority of the API endpoints have information in the Open API specification (i.e. Swagger docs) about what version of ACS that is required (i.e. in the API Explorer).

This version information is usually bachelor in the offset of the API endpoint description, as in the following screenshot:

dev-api-by-language-alf-rest-acs-required-version-1

Note that an API endpoint tin can be supported from a specific patch version of ACS, such as in the following screenshot:

dev-api-by-language-alf-rest-acs-required-version-2

If y'all are running an before version of ACS, which doesn't support the API endpoint, then yous would need to upgrade your ACS installation earlier starting to use this endpoint.

Tickets

Information technology's common to apply HTTP basic hallmark when trying out the ReST API.

Yet, the bones auth mechanism provides no confidentiality protection for the transmitted credentials. They are merely encoded with Base64 in transit, just not encrypted or hashed in any mode. Therefore, basic Hallmark is typically used in conjunction with HTTPS to provide confidentiality.

Alfresco Residue API as well provides another way of authenticating with the repository. The APIs as well support the Alfresco ticket mechanism. You tin Postal service the post-obit trunk to http://localhost:8080/alfresco/api/-default-/public/authentication/versions/ane/tickets to create a new ticket:

          {   "userId": "admin",   "password": "admin" }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍                  

The response provides the ticket in the id holding:

          {   "entry": {     "id": "TICKET_ed4981b4bbb15fc2713f7caaffd23982d0dd4e5c",     "userId": "admin"   } }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍                  

This ticket can and then be used instead of a username and countersign. Although the ReST API supports the alf_ticket query parameter, we do not recommend using it, a more secure arroyo is to use a HTTP header. The bones auth machinery is yet used i.east. sending an Authorisation header. Still, the base64 encoded username/password is replaced with the base64 encoded ticket.

How to become a ticket and how to apply it is explained here in the ReST API user guide.

Limiting result items

Past default the API volition return a maximum of 100 result items in any 1 asking, this can be controlled via the maxItems query parameter.

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?maxItems=5 request shows how you can limit the number of effect items to five.

This query parameter is supported across all collection endpoints.

Skipping result items

By default the API volition return consequence items starting from the beginning, it'southward possible to skip any number of result items using the skipCount query parameter. This is typically used for implementing paging or infinite scrolling in clients.

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?skipCount=2 asking shows how y'all can skip the get-go ii result items.

This query parameter is supported across all drove endpoints.

Ordering outcome items

All drove endpoints (those returning a list of result items) will have a default sort gild. It's possible to alter the sort society on some endpoints via the orderBy query parameter.

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/one/nodes/-my-/children?orderBy=sizeInBytes DESC request shows how yous can social club the nodes in your dwelling folder past the size of the content, starting with the largest detail.

The direction of the sorting can exist controlled by the DESC (descending) and ASC (ascending) keywords.

As previously mentioned, not all endpoints allow ordering to be controlled then you'll demand to consult the API Explorer to see whether the orderBy parameter is supported and what properties inside the response that can be used.

Filtering result items

Sometimes only a subset of the response items are required, several endpoints support this via the where query parameter.

The where parameter allows you to provide one or more than clauses defining what items y'all want to run into in the response. The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/ane/nodes/-my-/children?where=(isFile=true) request shows how you can limit the nodes in your home folder to just the files.

The where parameter is specific to each endpoint so y'all'll need to consult the API Explorer to run into firstly, whether the where parameter is supported and secondly, what expressions and clauses can be used.

Requesting optional particular information

We have taken what we're calling a "performance first" approach with the API. This means that each endpoint, by default, only returns the item information that is efficient to retrieve.

If additional processing is required on the server side to obtain the particular information, then it's made bachelor via the include query parameter.

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/one/nodes/-my-/children?include=properties,aspectNames request shows how you tin can too include the properties and aspects for each node in your domicile folder when listing its children.

As with the orderBy and where parameters, the include parameter is specific to the endpoint and so y'all'll need to consult the API Explorer to meet what extra particular information is available.

Limiting the item information

Sometimes bandwidth is a major consideration, such as when building a mobile client.

To cater for this scenario the API allows yous to control the amount of item information sent over the wire via the fields query parameter.

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?fields=id,name asking shows how yous tin limit the item response to only contain the id and name backdrop as shown in the response beneath:

          {   "listing": {     "pagination": {       "count": 3,       "hasMoreItems": false,       "totalItems": iii,       "skipCount": 0,       "maxItems": 100     },     "entries": [       {         "entry": {           "proper noun": "A Folder",           "id": "a5634765-ab0f-438a-8efd-bfa4139da8aa"         }       },       {         "entry": {           "name": "lorem-ipsum.txt",           "id": "5516aca4-df8b-43e8-8ff3-707316c60c6e"         }       },       {         "entry": {           "name": "prototype.jpg",           "id": "fc132aa5-6281-40bf-adee-5731e6ecb653"         }       }     ]   } }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍                  

The fields parameter works in conjunction with the include parameter so you don't have to echo yourself. For example, say y'all want to include the id, name and the optional aspectName properties in the response. It's and so possible to employ the fields=id,name&include=aspectNames query parameter cord. No need to specify the aspectName value again in the fields parameter.

The fields parameter is supported universally beyond all endpoints.

Person id alias

There are several endpoints across the API that expect a person id every bit part of the URL, this is OK if the client knows the person id, only there are some scenarios where it might not be known, for instance when using tickets.

For this scenario the API supports the -me- alias which can be substituted in any URL that expects personId.

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/people/-me- asking shows how this can be used to think the contour information of the currently authenticated user.

Well known node id aliases

There are several endpoints across the API that wait a node id every bit part of the URL, this is OK if the customer knows the node id, but there are some scenarios where it might non be known, for example when starting to navigate the folder hierarchy.

For this scenario the API supports the following node id aliases:

  • -root-: corresponds to the node id for the /Company Home folder.
  • -shared-: corresponds to the node id for the /Company Home/Shared binder.
  • -my-: corresponds to the node id for the current user'south home folder (i.eastward. /Visitor Home/User Homes/{userid}).

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children request shows how you lot tin list the contents (children) of the /Company Home folder without knowing its node id.

Creating multiple entities (items)

Supporting batch operations, such as updating the metadata for multiple items simultaneously, is something we programme to support in the future. However it's a little known fact that the API already has some basic batch capabilities when it comes to creating entities.

Most POST endpoints that create entities actually allow an array of objects to be passed in the body, which creates each i individually, but within the same transaction.

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children request shows how two folders can be created with the one request by passing the body shown below:

          [   {     "proper noun": "Folder One",     "nodeType": "cm:binder"   },   {     "proper noun": "Folder Two",     "nodeType": "cm:folder"   } ]‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍                  

The API returns a standard listing response providing the details on each entity that was created, in this instance, the ii folders:

          {   "list": {     "pagination": {       "count": two,       "hasMoreItems": simulated,       "totalItems": 2,       "skipCount": 0,       "maxItems": 100     },     "entries": [       {         "entry": {           "aspectNames": [             "cm:auditable"           ],           "createdAt": "2017-04-12T10:31:12.477+0000",           "isFolder": true,           "isFile": simulated,           "createdByUser": {             "id": "test",             "displayName": "Test User"           },           "modifiedAt": "2017-04-12T10:31:12.477+0000",           "modifiedByUser": {             "id": "exam",             "displayName": "Test User"           },           "proper name": "Binder One",           "id": "ecbec6fd-a273-4978-9b95-00a8e783948e",           "nodeType": "cm:folder",           "parentId": "062b8b2a-aa7e-4cdd-bfec-7fbcd16ecd85"         }       },       {         "entry": {           "aspectNames": [             "cm:auditable"           ],           "createdAt": "2017-04-12T10:31:12.501+0000",           "isFolder": true,           "isFile": simulated,           "createdByUser": {             "id": "examination",             "displayName": "Test User"           },           "modifiedAt": "2017-04-12T10:31:12.501+0000",           "modifiedByUser": {             "id": "exam",             "displayName": "Test User"           },           "name": "Folder Two",           "id": "18c82e9b-5a2f-44bf-bc77-1aca7346a24a",           "nodeType": "cm:folder",           "parentId": "062b8b2a-aa7e-4cdd-bfec-7fbcd16ecd85"         }       }     ]   } }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍                  

If the endpoint does not back up creating multiple entities an fault is returned.

Including the source entity for a collection

When returning a relationship collection for an entity, for example the children of a node or the members of a site, details of the entity are not included by default, to include them you can use the includeSource query parameter.

The http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?includeSource=true request shows how you'd include details of the user's dwelling folder when list its children, shown beneath in the source property:

          {   "list": {     "pagination": {       "count": 12,       "hasMoreItems": false,       "totalItems": 12,       "skipCount": 0,       "maxItems": 100     },         "entries": [ ... ],     "source": {       "name": "test",       "createdAt": "2017-02-20T11:01:39.647+0000",       "modifiedAt": "2017-04-12T10:31:12.509+0000",       "createdByUser": {         "id": "admin",         "displayName": "Administrator"       },       "modifiedByUser": {         "id": "exam",         "displayName": "Test User"       },       "isFolder": truthful,       "isFile": false,       "aspectNames": [         "cm:ownable",         "cm:auditable"       ],       "properties": {         "cm:owner": {           "id": "test",           "displayName": "Test User"         }       },       "nodeType": "cm:folder",       "parentId": "a9ad3bc4-d30f-4910-bee0-63d497e74a22",       "id": "062b8b2a-aa7e-4cdd-bfec-7fbcd16ecd85"     }   } }                  

Another example is returning details of a site when listing it'due south members, to do that you'd use the http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/sites/swsdp/members?includeSource=true URL.

The includeSource parameter is supported for all endpoints that include an entity and a relationship collection.

nelsonoursend1939.blogspot.com

Source: https://docs.alfresco.com/content-services/5.2/develop/rest-api-guide/

Postar um comentário for "Rest Api for File Upload in Alfresco"