How to get Page content from web service?
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...
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:
Also, this one is about adding/removing controls from the page and can be helpful in your case, as well:
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?
How do you get the content from the REST API?
What kind of content are you looking for? Generic Content?
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.
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.
Thanks for the response. This was very helpful!