Document APIs

Get Document List

OVERVIEW

Overview

This API call is used to retrieve a list of documents from the system.

Since v5.1

HTTP Request

GET  /api/2/documents?{parameters}

 

HTTP Headers
HTTP Request Header Description Example
Authorization The API Authorisation token "XXXXXXXXXXXXX"
Accept

The format of the expected response. 

  • "application/json"
  • "application/xml"

If no parameter is set, JSON is the default response given.

"application/xml"

 

API Accessibility

Access Type Description
API Token without user parameter Super admin, system admin, campaign admin, internal system admin, channel admin and editor can access the API.

 

URL Query Parameters

Parameter Description Example
fields

To select fields in response. Below are the possible values

  • In absence of field parameter, summary fields will appear in response like id, name, createdby,createddate,modifiedby,modifieddate,status,extension,icon,url.
  • all : will get full response.
  • CSV : will get only specified fields in response.
 fields=id,name
sort

 To sort with different columns.

  • +/-name : will sort based on document name
  • +/-createdby : will sort based on the user name who uploaded the document.
  • +/-createddate : will sort based on the createddate
  • +/-modifieddate : will sort based on the modifieddate (DEFAULT)
  • +/-status : will sort based on status
 sort=+name
status 

To filter the result based on status

  • Status CSV can be passed in this parameter. active,archived OR 1,2 are the possible values.
 status=active,archived
limit Maximum results to fetch. Default value is 30  limit=7
offset Is the page number, default value is 0.  offset=2
search Search keyword to search the documents. search=highq
source

This is toolbar source, for which the link is to be generated. Different source will result in different navigation parameter in the 'ckurl'. Below are the possible values

  • default
  • Basic
  • Oldcbg
  • Publication
  • Backgroudpages
  • CBGOnlyanswer
  • cbg
  • Glossary
  • features
  • topfeatures
  • Microsites
  • MicrositesTopNav
  • Campaigner
  • DelegateUserAutoLoginLink
  • DelegateRegistrationTemplate
  • textlibrary
  • errorPageMicrosite
  • createContent
  • CBGGlossary
  • api (In absense of any source, api is the default value)
source=publication

 

HTTP Response

Success

HTTP response 200 with a list of Document summary Objects

(Example below)

 

Example HTTP Request and HTTP Response

GET  https://example.com/context/api/2/documents?fields=all

 

JSON Response

{
    "total": 1,
    "totalcount": 2,
    "currentpage": 0,
    "document": [
        {
            "id": 1015,
            "name": "PD20308",
            "createdby": {
                "userid": 27,
                "username": "Rishit Patel"
            },
            "createddate": "26 Feb 2019 11:16",
            "modifiedby": {
                "userid": 27,
                "username": "Rishit Patel"
            },
            "modifieddate": "26 Feb 2019 11:16",
            "attachmentid": 1015,
            "attachmentname": "PD20308.jpg",
            "extension": "jpg",
            "size": "118.57 KB",
            "status": "active",
            "icon": {
                "url": "https://example.com/context/images/v4/fileicon/large_jpg.svg",
                "title": "Image",
                "class": {
                    "small": "icon-highq-image"
                }
            },
            "url": "https://example.com/context/attachment_dw.action?attkey=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQJsWJiCH2WAWHb%2FPDBPVvgseOxeWfgNw9&fromContentView=1&nav=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQuf6KjHLHOBw%3D&attdocparam=pB7HEsg%2FZ312Bk8OIuOIH1c%2BY4beLEAe2c%2BkuMdnaHo%3D",
            "ckurl": "https://example.com/context/attachment_dw.action?attkey=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQJsWJiCH2WAWHb%2FPDBPVvgseOxeWfgNw9&nav=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQ9jpaytfwQcI%3D&attdocparam=pB7HEsg%2FZ312Bk8OIuOIH1c%2BY4beLEAe2c%2BkuMdnaHo%3D&fromContentView=1",
            "downloadurl": "https://example.com/context/attachment_dw.action?attkey=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQJsWJiCH2WAWHb%2FPDBPVvgseOxeWfgNw9&nav=&uid=&fromContentView=1"
        }
    ]
}

 

XML Response

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<documents>
    <total>1</total>
    <totalcount>2</totalcount>
    <currentpage>0</currentpage>
    <document>
        <id>1015</id>
        <name>PD20308</name>
        <createdby>
            <userid>27</userid>
            <username>Rishit Patel</username>
        </createdby>
        <createddate>26 Feb 2019 11:16</createddate>
        <modifiedby>
            <userid>27</userid>
            <username>Rishit Patel</username>
        </modifiedby>
        <modifieddate>26 Feb 2019 11:16</modifieddate>
        <attachmentid>1015</attachmentid>
        <attachmentname>PD20308.jpg</attachmentname>
        <extension>jpg</extension>
        <size>118.57 KB</size>
        <status>active</status>
        <icon>
            <class>
                <small>icon-highq-image</small>
            </class>
            <url>https://nitesh.local.com/5_0/images/v4/fileicon/large_jpg.svg</url>
            <title>Image</title>
        </icon>
        <url>https://example.com/context/attachment_dw.action?attkey=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQJsWJiCH2WAWHb%2FPDBPVvgseOxeWfgNw9&amp;fromContentView=1&amp;nav=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQuf6KjHLHOBw%3D&amp;attdocparam=pB7HEsg%2FZ312Bk8OIuOIH1c%2BY4beLEAe2c%2BkuMdnaHo%3D</url>
        <ckurl>https://example.com/context/attachment_dw.action?attkey=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQJsWJiCH2WAWHb%2FPDBPVvgseOxeWfgNw9&amp;nav=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQ9jpaytfwQcI%3D&amp;attdocparam=pB7HEsg%2FZ312Bk8OIuOIH1c%2BY4beLEAe2c%2BkuMdnaHo%3D&amp;fromContentView=1</ckurl>
        <downloadurl>https://example.com/context/attachment_dw.action?attkey=FRbANEucS95NMLRN47z%2BeeOgEFCt8EGQJsWJiCH2WAWHb%2FPDBPVvgseOxeWfgNw9&amp;nav=&amp;uid=&amp;fromContentView=1</downloadurl>
    </document>
</documents>

 

Validation Messages
Description Response Response Code
When offset is negative or not a number. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
    <ref>106</ref>
    <summary>Invalid parameter: offset</summary>
</error>
400
When limit is not a positive number. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
    <ref>107</ref>
    <summary>Invalid parameter: limit</summary>
</error>
400
When invalid sort parameter is passed <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
    <ref>79</ref>
    <summary>Invalid parameter: sort</summary>
</error>
400
When source parameter is invalid <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
    <ref>236</ref>
    <summary>Invalid parameter: source</summary>
</error>
400

 

 

Comments


0 Comments

Last Updated: Nov 08,2024