0

I am using the Sharepoint 2010 rest api to get data of a custom content type item in "Pages" folder. The data is returned but I can not find the content of a custom RichTextField column. Is there any special setting or how should I do to get this content value ? Thanks

====Update the return data ====
Here is the returned data from the browser: enter image description here


I want to get the Page Content field:

enter image description here

2
  • Is your description column is in "_Hidden" field group? Commented Sep 11, 2015 at 6:51
  • Hi Sekhar, it is not hidden.
    – Cuong Phan
    Commented Sep 12, 2015 at 0:12

2 Answers 2

0

Getting PublishingPageContent using REST doesn't seem to be possible especially in SP 2010 where you have limited options. You can use JSOM to do this:

function retrieveListItems() {

var clientContext = new SP.ClientContext(siteurl);
var oList = clientContext.get_web().get_lists().getByTitle('Pages');

var camlQuery = new SP.CamlQuery();
//camlQuery.set_viewXml('');
this.collListItem = oList.getItems(camlQuery);

clientContext.load(collListItem);

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));  
}
function onQuerySucceeded(sender, args) {

var listItemInfo = '';

var listItemEnumerator = collListItem.getEnumerator();

while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    listItemInfo += '\nID: ' + oListItem.get_id() +             
        '\PageContent: ' + oListItem.get_item('PublishingPageContent');
}
console.log(listItemInfo); // returns ID and PageContent
}
function onQueryFailed(sender, args) {

alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
10
  • Thank Akhoy, I need call the SP webservice from an iphone application. Does the JSOM work with my app. Also, I am trying with the SOAP api but it requires the web id to retrieve.
    – Cuong Phan
    Commented Sep 11, 2015 at 23:58
  • In that case, I don't think this would work. You'd have to create a custom web service and call that from the iPhone app. This will only work from within SharePoint so maybe you could have a custom list where you are outputting this and then querying that. But it wont work from within the app.
    – Akhoy
    Commented Sep 12, 2015 at 15:02
  • Thanks, I am referring this post msdn.microsoft.com/en-us/library/office/… to create a custom webservice for my app.
    – Cuong Phan
    Commented Sep 13, 2015 at 12:20
  • hi Akhoy, I am testing the new custom webservice. I call it from jquery but the request is 401 - Unauthorized error. I tried the soap /_vti_bin/authentication.asmx?op=Login but it's not luck. How can I authenticate for my html file ?
    – Cuong Phan
    Commented Sep 13, 2015 at 16:49
  • The user wouldn't have permissions. Check if this helps : dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/08/03/…
    – Akhoy
    Commented Sep 14, 2015 at 6:13
0

First, I would recommend to double check the internal name of your field, just in case.

do you access the data retrieved like this ?

function onSuccess(data, request) 
{
    var itemInfo = data.d;
    // if your rich text field internal name is "Description"
    alert(itemInfo.Description);
}

if your field is not here, can you try to modify the rest URL by adding

?$select=Title,MyCustomFieldInternalName

at the end. See if you can retrieve Title and your field.

EDIT It doesn't seem possible to retrieve the PublishingPageContent via REST in SharePoint 2010. It is in SharePoint 2013 : How to get content of html by using REST service in SharePoint 2013

5
  • Thank Sylvain, I checked the return data but dont see this content.
    – Cuong Phan
    Commented Sep 11, 2015 at 4:19
  • ok, thanks for the details. I added something which is worth trying. Commented Sep 11, 2015 at 5:37
  • Hi, The browser returns this error "Type 'Microsoft.SharePoint.DataService.PagesItem' does not have a property named 'PublishingPageContent"' when I select this field. Also, if I select the Title only, it is success.
    – Cuong Phan
    Commented Sep 11, 2015 at 6:34
  • I am sorry I think it is not possible in SharePoint 2010, Akhoy's solution is a way you can explore. Commented Sep 11, 2015 at 8:42
  • Thanks for your supporting. I will try Akhoy's solution.
    – Cuong Phan
    Commented Sep 12, 2015 at 0:00

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.