Client Pay Portal
 kentico

Retrieving Attachment Info using the Kentico REST Service

The REST service that comes with Kentico CMS is a great resource for any project that needs to extend the functionality of deleting and updating content through a programmatic interface. This service has a ton of great features that allow for content retrieval, document manipulation, and object data retrieval, all of which simplify interacting with the system from an external application. While we have used the service to return document information many times in the past, I recently had the requirement to return document attachment info, as well. REST Service to the rescue!

This guide will show you how you can quickly get back document attachments with a few short calls to the service.

Kentico Versions:
V 6.0
V 7.0


1. Get the Document ID that has the attachments

The first step in getting you attachments is to get the document ID of the document you want the attachments for (while grammatically correct, that statement is ridiculous!).

The REST Service call to get the document info would look like this:

http://kenticodemo.bitwizards.com/rest/content/site/currentsitee/en-us/document/home/attachmenttest 

This is what you would get back an what value you are looing for:
 
 


2. Get the Attachments for the document

In order to return the attachments, you’ll need to make a second call to the REST service. This call can return the attachment info, or the info and the file in a binary format.

This is the call you would make to get the attachments:

http://kenticodemo.bitwizards.com/rest/cms.attachment?binary=true&where=AttachmentDocumentID=1854 

Standard Info Call

 
Info Call with Binary
 

 

With this call you can get all the great information there is to know about your attachments and even the binary data. With that you can stream it to your favorite object and finally have the satisfaction of knowing you have lived a full life.

The REST service in Kentico is one of the best features of the platform and the easiest to integrate into your 3rd party systems. I highly recommend you check it out and see how you can simplify your systems.


Tip

You can check out more on the REST service in the developer's guide here.
Hope this tip helps!
 

Author

Wiz E. Wig, Mascot & Director of Magic
Wiz E. Wig

Director of Magic