I have a repeater in a user control and I databind it in code behind like so:

                var items = list.Items.Cast<SPListItem>()
                .OrderByDescending(a => a[SPBuiltInFieldId.Modified])
                .Where(a => a.HasPublishedVersion)
                .Select(a => new
                    Title = a.Title,
                    Comments = a[FieldNames.Comments],
                    RollupImage = a[FieldNames.RollupImage],
                    PageContent = a[FieldNames.PageContent],
                    NewsDate = a[SPBuiltInFieldId.Modified],
                    Url = SPUtility.ConcatUrls(web.Url, a.Url)

                rptNews.DataSource = items;

I now try to do the same but with REST and jQuery instead, I got it working for normal text fields but when I try to get the URL and RollupImage I get into trouble ("undefined").

$("#<%=lblReadMore.ClientID%>").click(function () {
    var displayedItems = $(".news-item").length;
    var url = L_Menu_BaseUrl + "/content/_vti_bin/ListData.svc/Pages?$skip=" + displayedItems + "&top=3?$orderby=Modified";

     function (data) {
          function (i, result) {
              $('<div class="news-item noindex"><table><tr><td class="news-item-image">' + result.PublishingRollupImage + '</td><td class="news-item-content"><h2>' + result.Title + '</h2><p>' + result.Comments + '<a class="moreButton" href="' + result.Url + '">Read More</a></p></td></tr></table></div>').appendTo("#HomePageNews");


The internal name for rollupimage is PublishingRollupImage but when I use this I get undefined.

Also, in the C# code I filter on a.HasPublishedVersion, is this taken care of automatically with the REST API or do I need a check for this?

Thanks in advance.

Edit: Updated code:

function GetImage(id) {
    var ctx = new SP.ClientContext("/content/");
    var targetList = ctx.get_web().get_lists().getByTitle('Pages');
    targetListItem = targetList.getItemById(id);
    ctx.load(targetListItem, 'PublishingRollupImage');
    ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded(sender, args) {

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

function LoadAllNews() {
    var siteUrl = L_Menu_BaseUrl + "/content/";
    var listUrl = siteUrl + "_vti_bin/ListData.svc/Pages?$filter=ApprovalStatus eq '0'";

     function (data) {
          function (i, result) {
              $('<div class="news-item noindex"><table><tr><td class="news-item-image"></td><td class="news-item-content"><h2>' + result.Title + '</h2><p>' + result.Comments + '<a class="moreButton" href="' + result.Path + "/" + result.Name + '"> Read More</a></p></td></tr></table></div>').appendTo("#HomePageNews");
  • OK I figured Url out by using firebug so it's result.Path + "/" + result.Name – John Oct 2 '12 at 2:27

Would it be possible to use the Client Object Model?

This works for me:

var ctx = new SP.ClientContext();
var items = ctx.get_web().get_lists().getByTitle('Pages').getItems(new SP.CamlQuery());
ctx.executeQueryAsync(function() {
  // Get the first items rollup image, just as an example
  var rollupImage = items.getItemAtIndex(0).get_item('PublishingRollupImage');
  • I tried to use something like GetImage(result.Id) in my function and a function with your code above but I'm not sure how to return the URL for each item, I only get "Uncaught Error: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested." Updated my question – John Oct 2 '12 at 8:18
  • 1
    When I run that code I get the URL. But perhaps you got a lot of data, maybe you must do a items.getItemAtIndex(0).get_item('PublishingRollupImage');ctx.load();ctx.executeQueryAsync(function(){console.log(items.getItemAtIndex(0).get_item('PublishingRollupImage'))}) after the comment (// Get the first...) – eirikb Oct 2 '12 at 9:05
  • I get the URL when I run the code but now when I pass on the ID from another method and try to return the URL to the calling method. It works fine to use alert('..') but not to return a value. – John Oct 2 '12 at 9:31
  • You can't return a value, it's asynchronous, you need to write a callback. Like: function Get(cb){var ctx=...; ctx.executeQueryAsync(function(){ var rollupImage = ...; cb(rollupImage);})} – eirikb Oct 2 '12 at 10:10
  • Thanks for your help eirikb, do you have a link to somewhere where I can read more about async and callback with the SharePoint 2010 client object model? – John Oct 2 '12 at 23:33

It does not seem possible to retrieve Publishing Image fields using SharePoint REST List Item endpoint.

But there is a workaround, publishing fields could be retrieved using ListItem.FieldValuesAsHtml property via SharePoint REST endpoint as demonstrated below.

How to retrieve Publishing fields using SharePoint 2013 REST

function getJson(endpointUri, success, error) 
       url: endpointUri,   
       type: "GET",   
       processData: false,  
       contentType: "application/json;odata=verbose",
       headers: {   
          "Accept": "application/json;odata=verbose"
       success: success,
       error: error

function getPublishingPage(webUrl,listName,listItemId,publishingProperties, success, failure) 
    var itemUri =  webUrl + "/_api/web/lists/getbytitle('" + listName + "')/items(" + listItemId + ")";  
           var pageItem = data.d;

           var selectProperties = [];  
           for(var idx in publishingProperties){
           if(selectProperties.length > 0) {
              //construct an additional query 
              var query = '/FieldValuesAsHtml?$select=' + selectProperties.join(',');
              var endpointUri = pageItem['__metadata'].uri + query;
                    for(var property in data.d){
                       if(property == "__metadata") continue; 
                       pageItem[property] = data.d[property];   
           else {


The following example demonstrates how to retrieve page fields including publishing fields, such as PublishingRollupImage:


function printPageDetails(pageItem)
    console.log('Page Content: ' + pageItem.PublishingPageContent);
    console.log('Page Title: ' + pageItem.Title);
    console.log('Page Rollup Image ' + pageItem.PublishingRollupImage);

function logError(error){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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