+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to get Page content from web service?

How to get Page content from web service?

8 posts, 0 answered
  1. Tim Haynes
    Tim Haynes avatar
    8 posts
    Registered:
    12 May 2010
    26 Jan 2012
    Link to this post
    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
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    31 Jan 2012
    Link to this post
    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
  3. Travis
    Travis avatar
    86 posts
    Registered:
    15 Oct 2008
    15 May 2012
    Link to this post
    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
  4. Chris
    Chris avatar
    6 posts
    Registered:
    11 Nov 2013
    13 Feb 2014 in reply to Svetoslav Petsov
    Link to this post
    How do you get the content from the REST API?
  5. Travis
    Travis avatar
    86 posts
    Registered:
    15 Oct 2008
    13 Feb 2014 in reply to Chris
    Link to this post
    What kind of content are you looking for? Generic Content?
  6. Chris
    Chris avatar
    6 posts
    Registered:
    11 Nov 2013
    14 Feb 2014 in reply to Travis
    Link to this post
    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.
  7. Travis
    Travis avatar
    86 posts
    Registered:
    15 Oct 2008
    14 Feb 2014
    Link to this post
    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.
  8. Chris
    Chris avatar
    6 posts
    Registered:
    11 Nov 2013
    14 Feb 2014 in reply to Travis
    Link to this post
    Thanks for the response. This was very helpful!
8 posts, 0 answered