Below rest api code get publish feature fields
function getPublishingPage(webUrl,listName,listItemId,publishingProperties, success, failure)
{
var itemUri = webUrl + "/_api/web/lists/getbytitle('" + listName + "')/items(" + listItemId + ")";
getJson(itemUri,
function(data){
var pageItem = data.d;
var selectProperties = [];
for(var idx in publishingProperties){
if(!pageItem.hasOwnProperty(publishingProperties[idx])){
selectProperties.push(publishingProperties[idx]);
}
}
if(selectProperties.length > 0) {
//construct an additional query
var query = '/FieldValuesAsHtml?$select=' + selectProperties.join(',');
var endpointUri = pageItem['__metadata'].uri + query;
getJson(endpointUri,
function(data){
for(var property in data.d){
if(property == "__metadata") continue;
pageItem[property] = data.d[property];
}
success(pageItem);
},
failure);
}
else {
success(pageItem);
}
},
failure);
}
No comments:
Post a Comment