How to get Page content from web service?

Posted by Community Admin on 04-Aug-2018 20:27

How to get Page content from web service?

All Replies

Posted by Community Admin on 26-Jan-2012 00:00

Hi

When I call .../Sitefinity/Services/Pages/PagesService.svc/<guid> I get a lot of details about the given page.  What I don't get is any of the controls that are on the page, or their contents.

How can I use the web service API to get the content on a given page?  Or am I thinking about Pages wrong...

Thanks

Posted by Community Admin on 31-Jan-2012 00:00

Hello,

 The PagesService returns a serialized object that holds information about the node with the guid that you specified. if you can use our API (you have references to Sitefinity assemblies and you are trying to do that from the same application), you do not need to use the services. You can directly query the page and see the controls collection, which is a property of the PageData. Here's a page from our documentation that can help you with querying pages with the API:
http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/pages/querying-pages 
Also, this one is about adding/removing controls from the page and can be helpful in your case, as well:
http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/pages/adding-and-removing-controls 

Greetings,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 15-May-2012 00:00

Hello,
I'd like to use this in the way the original poster is suggesting, that is, I'd like to be able to pull control data from the web services. Is this possible? if so, what services must I query and what methods?

Thanks

Posted by Community Admin on 13-Feb-2014 00:00

How do you get the content from the REST API?

Posted by Community Admin on 13-Feb-2014 00:00

What kind of content are you looking for? Generic Content?

Posted by Community Admin on 14-Feb-2014 00:00

I'm looking for say a list of content controls that are on the page so that I could edit some text. For instance, a hard coded url that's in a content block. Thanks.

Posted by Community Admin on 14-Feb-2014 00:00

Hmm, unfortunately I'm not sure how you achieve that using the built in services. When we have updated control properties in the past it has been using built-in server side (code behind) calls. 

To do so, we loop through a PageNode's Control collection, looking for a control of a particular type. Once we've found our control collection, we loop through their properties and adjust what we need to. Then we publish the page. Using this method, you'll need to get your page node from the PageManager, then iterate through its .Page.Controls collection. Then, you'll need to check that PageControls properties (PageControl.Properties) for the property name you're looking for (I'm not 100% sure what that is for a content block on a page, but my guess would be "Content") and then you should be able to manipulate it from there. To publish a page, I do the following:

var bag = new Dictionary<string, string> "ContentType", typeof (PageNode).FullName;
WorkflowManager.MessageWorkflow(page.Id, typeof(PageNode), null, "Publish", false, bag);


I hope this is helpful.

Posted by Community Admin on 14-Feb-2014 00:00

Thanks for the response. This was very helpful!

This thread is closed