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

Forums / Developing with Sitefinity / Creating pages via the API

Creating pages via the API

5 posts, 1 answered
  1. Dave
    Dave avatar
    29 posts
    Registered:
    31 Oct 2011
    13 Nov 2011
    Link to this post
    I need to import a very large number of pages from our existing (non-Sitefinity) site.

    I've built a WinForms app that retrieves and parses the existing pages to grab the content that I need. However, I'm at a loss as to how to get that content into Sitefinity.

    I spent quite a bit of time today trying to use the ~/Sitefinity/Services/Pages/PagesService.svc, but I can't figure out how to give my WinForms app permission to call the service.

    Finally, I decided to forego the web service API. Instead, I created a new web service that, in turn, uses some of the code from http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-pages-creating-pages.html to create a page. However, I'm again running into authorization issues.
    I added this method to my web service:

    [WebMethod]
    public string WhoAmI()
    {
        return "Running as User : " +
            Thread.CurrentPrincipal.Identity.Name;
    }

    which, when called from my WinForms app, returns "Anonymous."

    Since this is a one-time import, I'm happy to give the Anonymous user rights to everything on the dev server. However, I'm not sure how to do that.

    Help!

    Better yet, are there any functioning examples available of using the Sitefinity services from a desktop application?


  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    16 Nov 2011
    Link to this post
    Hi David,

    Can you please take a look at this blog post, where we've explained in details a simple scenario of using Sitefinity RESTful services, including authentication. We have provided a code sample of a working application as well, I believe you might find it useful. If there's anything else we can help you with, please let us know.

    Kind regards,
    Boyan Barnev
    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
    Answered
  3. Dave
    Dave avatar
    29 posts
    Registered:
    31 Oct 2011
    16 Nov 2011
    Link to this post
    Hi Boyan,

    Nice post; looks like it addresses my issues. I'm off to import some pages now!

  4. Tim Haynes
    Tim Haynes avatar
    8 posts
    Registered:
    12 May 2010
    23 Jan 2012
    Link to this post
    This is a great blog post; thanks for sharing it.

    Can you please confirm whether you must log in before reading publicly-available data?  I ran the sample site from the blog post, and it is logging in just to get News items.  In my site, News items are publicly readable, yet I must still log in when reading them through the web service.

    Thanks
    Tim
  5. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    26 Jan 2012
    Link to this post
    Hi Tim,

    Yes, indeed you must log in, even though the content is published, but this is not related to a security restriction imposed from Sitefinity, but rater a requirement for  WCF services communication to be established.

    Regards,
    Boyan Barnev
    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
5 posts, 1 answered