I have to display other site collection list data in root site. I am using REST API call to do that. But I am stuck while fetching 'DocIcon'. Can anyone tell me how can I get it?

Here is my code sample:

var folderUrl = '/sites/docs/Health%20safety%20and%20environment/Emergency%20Response';
var url ="http://sharepoint.com/sites/docs/_api/Web/GetFolderByServerRelativeUrl('" + folderUrl + "')?$expand=Folders,Files";


for(var i = 0; i < data.Files.length;i++){
        $('<td>').text(data.Files[i].TimeLastModified.substring(0, 10))).appendTo('#records_table');

1 Answer 1


The "DocIcon" property will not get you the icon itself but the file extension.

You can use mapToIcon method from the SPWeb object in JavaScript to get the image url.

Example : http://onlinecoder.blogspot.ca/2014/03/get-oob-document-type-icon-using.html

  • I am not able to get office files icons Commented Jul 9, 2015 at 9:16
  • Do you get an error ?
    – JayHell
    Commented Jul 9, 2015 at 13:07
  • No its blank image. But I found a work around. I checked if '.gif' icon exist or not. If it does not exist I check if '.png' icon exist. If both are missing then I display general file icon else which ever is exist. Commented Jul 10, 2015 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.