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

Forums / Developing with Sitefinity / UnauthorizedAccessException when trying to create new page via api

UnauthorizedAccessException when trying to create new page via api

2 posts, 0 answered
  1. Tom
    Tom avatar
    19 posts
    Registered:
    28 Nov 2014
    05 Dec 2014
    Link to this post

    Hi, I'm following the sitefinity development course on pluralsight and I get a UnauthorizedAccessException when I try and create a new page via the api in c#.

    The code is:
    Guid pageDataId = Guid.NewGuid();

    App.WorkWith().Page().
    CreateNewStandardPage(SiteInitializer.CurrentFrontendRootNodeId, pageDataId)
    .Do(p =>
    {
    p.Title = "Pluralsight Title";
    p.Name = "Pluralsight Name";
    p.Description = "Pluralsight Desc";
    p.UrlName = "Pluralsight UrlMame";
    p.ShowInNavigation = true;
    p.DateCreated = DateTime.UtcNow;
    p.LastModified = DateTime.UtcNow;
    p.Page.HtmlTitle = "Pluralsight Page HTML Title";
    p.Page.Description = "Pluralsight Page Desc";
    p.Page.Title = "Pluralsight Page Title";
    }).SaveChanges();

    and the exception message is:
    {"You are not authorized to 'Create child pages of this page' ('Pages')."}

    The code is exactly the same as that in the course - I just think it may be from an earlier version of SiteFinity. I'm using 7.3.5320

    Any help appreciated!

    Tom.

     

  2. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    06 Dec 2016
    09 Dec 2014
    Link to this post
    Hi,

    The problem is coming from the fact that you are not logged in the backend of you project as administrator when the code has been executed. By default unauthenticated users are not allowed to modify/edit/delete content items and est.

    Regards,
    Stefani Tacheva
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered