Thursday, 12 February 2015

Reading List and List Attributes of List using REST API SharePoint 2013

We can read a SharePoint List/Library and its all attributes by consuming the REST endpoint:

http://server/_api/lists/getbytitle('listname')

For example, below url retrieves all the attributes of the library (or list) Account.

https://xxx.sharepoint.com/_api/lists/getbytitle(‘Account’)


Example JSON response (part of it) from the above REST call. Marked are some of the attributes required for us:

  "AllowContentTypes": true,
        "BaseTemplate": 101,
        "BaseType": 1,
        "ContentTypesEnabled": false,
        "CrawlNonDefaultViews": false,
        "Created": "2015-01-05T11:06:56Z",
        "DefaultContentApprovalWorkflowId": "00000000-0000-0000-0000-000000000000",
        "Description": "",
        "Direction": "none",
        "DocumentTemplateUrl": "/SalesForce Files/Forms/template.dotx",
        "DraftVersionVisibility": 0,
        "EnableAttachments": false,
        "EnableFolderCreation": true,
        "EnableMinorVersions": false,
        "EnableModeration": false,
        "EnableVersioning": true,
        "EntityTypeName": "SalesForce_x0020_Files",
        "ForceCheckout": false,
        "HasExternalDataSource": false,
        "Hidden": false,
        "Id": "d5f89928-6c33-476d-a80c-54fcf0d57164",
        "ImageUrl": "/_layouts/15/images/itdl.png?rev=38",
        "IrmEnabled": false,
        "IrmExpire": false,
        "IrmReject": false,
        "IsApplicationList": false,
        "IsCatalog": false,
        "IsPrivate": false,
        "ItemCount": 3,
        "LastItemDeletedDate": "2015-01-05T11:27:20Z",
        "LastItemModifiedDate": "2015-01-16T07:22:05Z",
        "ListItemEntityTypeFullName": "SP.Data.SalesForce_x0020_FilesItem",
        "MajorVersionLimit": 0,
        "MajorWithMinorVersionsLimit": 0,
        "MultipleDataList": false,
        "NoCrawl": false,
        "ParentWebUrl": "/",
        "ParserDisabled": false,
        "ServerTemplateCanCreateFolders": true,
        "TemplateFeatureId": "00bfea71-e717-4e80-aa17-d0c71b360101",
        "Title": "SalesForce Files"

Here as i marked in yellow:

BaseTemplate
100: List
101: Library
Created
Created Date
Description
Description of the List
Hidden
False. False indicates that it is not hidden and not system defined.
Id
Unique id of the List
ItemCount
Number of items in the Lisut
LastItemModifiedDate
Last modified date
title
Name of the List