api for document view

cancel
Showing results for 
Search instead for 
Did you mean: 
aishu
Active Member

api for document view

Dear Team,

I need a api for display an document from site.

i have reffered the below api - 

http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/{id}/renditions/{renditionId}/content

but i am not understood how to get renditionid of document.

 

Kinldy suggest!

Thank you.

Kind regards,

Aishu.

15 Replies
afaust
Master

Re: api for document view

You get the IDs of renditions by first querying the listRenditions API (.../nodes/{id}/renditions)

aishu
Active Member

Re: api for document view

dear afaust,

i have refered this link,

as per api the document in the form of pdf so i have mentioned renditionid = pdf.

https://alfrescosite-domain name/alfresco/api/-default-/public/alfresco/versions/1/nodes/3268c9f0-14...

but its showing below error

{"error":{"errorKey":"pdf is not applicable for the node's mimeType application/pdf","statusCode":404,"briefSummary":"0623809817 pdf is not applicable for the node's mimeType application/pdf","stackTrace":"For security reasons the stack trace is no longer displayed, but the property is kept for previous versions","descriptionURL":"https://api-explorer.alfresco.com"}}

kindly suggest on this.

 

aishu
Active Member

Re: api for document view

i have tried the api for renderation content-

https://----.com/alfresco/api/-default-/public/alfresco/versions/1/nodes/3268c9f0-1473-4913-8f21-ad8...

but its showing below error-

{"error":{"errorKey":"Thumbnail was not found for [pdf]","statusCode":404,"briefSummary":"0623812230 Thumbnail was not found for [pdf]","stackTrace":"For security reasons the stack trace is no longer displayed, but the property is kept for previous versions","descriptionURL":"https://api-explorer.alfresco.com"}}

kindly suggest!

 

Thank you. 

adelaidenx
Alfresco Employee

Re: api for document view

Hi @aishu 

I think you may need to check which renditions are available for your nodeID, pick the renditionID you want (if status=CREATED) or request it (if status=NOT_CREATED), and finally get the rendition content using the nodeID and renditionID.

 

Back to your original question: you'll find the renditionID in the response from List Renditions as @afaust mentioned.

So in the Response Body snippet below, avatar, doclib, imgpreview and pdf are valid parameters. 

{
  "list": {
    "pagination": {
      "count": 7,
      "hasMoreItems": false,
      "totalItems": 7,
      "skipCount": 0,
      "maxItems": 100
    },
    "entries": [
      {
        "entry": {
          "id": "avatar",
          "content": {
            "mimeType": "image/png",
            "mimeTypeName": "PNG Image",
            "sizeInBytes": 1387,
            "encoding": "UTF-8"
          },
          "status": "CREATED"
        }
      },
      ...
      {
        "entry": {
          "id": "doclib",
          "content": {
            "mimeType": "image/png",
            "mimeTypeName": "PNG Image",
            "sizeInBytes": 2388,
            "encoding": "UTF-8"
          },
          "status": "CREATED"
        }
      },
      {
        "entry": {
          "id": "imgpreview",
          "content": {
            "mimeType": "image/jpeg",
            "mimeTypeName": "JPEG Image"
          },
          "status": "NOT_CREATED"
        }
      },
      ...
      {
        "entry": {
          "id": "pdf",
          "content": {
            "mimeType": "application/pdf",
            "mimeTypeName": "Adobe PDF Document",
            "sizeInBytes": 22800,
            "encoding": "UTF-8"
          },
          "status": "CREATED"
        }
      },
      ...
    ]
  }
}

Note: I cropped out three renditions in the above response.

HTH

Technical Writer in Alfresco User Assistance Team
Problem solved? Click Accept as Solution!
adelaidenx
Alfresco Employee

Re: api for document view

Hi @aishu 

I think you may need to check which renditions are available for your nodeID, pick the renditionID you want (if status=CREATED) or request it (if status=NOT_CREATED), and finally get the rendition content using the nodeID and renditionID.

Back to your original question: you'll find the renditionID in the response from 'listRenditions' as mentioned by @afaust.

So in the Response Body snippet below, avatar, doclib, imgpreview and pdf are valid parameters.

{
  "list": {
    "pagination": {
      "count": 7,
      "hasMoreItems": false,
      "totalItems": 7,
      "skipCount": 0,
      "maxItems": 100
    },
    "entries": [
      {
        "entry": {
          "id": "avatar",
          "content": {
            "mimeType": "image/png",
            "mimeTypeName": "PNG Image",
            "sizeInBytes": 1387,
            "encoding": "UTF-8"
          },
          "status": "CREATED"
        }
      },
      {
        "entry": {
          "id": "doclib",
          "content": {
            "mimeType": "image/png",
            "mimeTypeName": "PNG Image",
            "sizeInBytes": 2388,
            "encoding": "UTF-8"
          },
          "status": "CREATED"
        }
      },
      {
        "entry": {
          "id": "imgpreview",
          "content": {
            "mimeType": "image/jpeg",
            "mimeTypeName": "JPEG Image"
          },
          "status": "NOT_CREATED"
        }
      },
      {
        "entry": {
          "id": "pdf",
          "content": {
            "mimeType": "application/pdf",
            "mimeTypeName": "Adobe PDF Document",
            "sizeInBytes": 22800,
            "encoding": "UTF-8"
          },
          "status": "CREATED"
        }
      },
    ]
  }
}

Note: I cropped out three renditions in the above response.

HTH

Technical Writer in Alfresco User Assistance Team
Problem solved? Click Accept as Solution!
aishu
Active Member

Re: api for document view

Dear 

{"list":{"pagination":{"count":0,"hasMoreItems":false,"totalItems":0,"skipCount":0,"maxItems":100},"entries":[]}}

thank you.

Regards, 

Aishu.

adelaidenx
Alfresco Employee

Re: api for document view

Hi @aishu 

What response message (HTTP status code) are you getting?

These codes are documented in the List renditions: REST API Explorer.

Technical Writer in Alfresco User Assistance Team
Problem solved? Click Accept as Solution!
aishu
Active Member

Re: api for document view

hi @adelaidenx ,

i have followed same codes mentioned in  List renditions: REST API Explorer..

but no data or content present in entries- response header.

refer attached image.5.png

 

adelaidenx
Alfresco Employee

Re: api for document view

Hi @aishu 

So it looks like no renditions are listed for that node where status=CREATED.

What happens if you remove the status in the url?

Technical Writer in Alfresco User Assistance Team
Problem solved? Click Accept as Solution!