More in this section

Forums / Bugs & Issues / Can't create News Item through API, get You are not authorized to 'Create {0}' ('General').

Can't create News Item through API, get You are not authorized to 'Create {0}' ('General').

4 posts, 0 answered
  1. Jason
    Jason avatar
    10 posts
    Registered:
    08 Feb 2012
    15 Feb 2012
    Link to this post
    I'm working through the SiteFinity Developer training and was working on how to create a news item. I've double checked my code (attached) but I get the following error (You are not authorized to 'Create {0}' ('General'). )

    In my searches it looks like this is a permissions thing. I've gone to news item permissions and it looks as though I have the administrator applied.

    I'm working on a trial of SiteFinity 4.4 locally on my laptio with Visual Studio 2010.
  2. Jason
    Jason avatar
    10 posts
    Registered:
    08 Feb 2012
    15 Feb 2012
    Link to this post

    Guess code didn't attach

    Format Code Block
    protected void Page_Load(object sender, EventArgs e)
            {
                #region Normal API
                /*
                //Initialize the content manager with the default provider
                NewsManager manager = NewsManager.GetManager();

                //Create a new generic item
                NewsItem item = manager.CreateNewsItem();

                //Set item properties
                item.Title = "New News Content";
                item.DateCreated = DateTime.UtcNow;
                item.PublicationDate = DateTime.UtcNow.AddDays(1);
                item.ExpirationDate = DateTime.UtcNow.AddDays(30);
                item.Author = "Jason McIntosh";
                item.Content="<h1>New News Story From The Normal API</h1>";

                //generate URL and save changes
                manager.RecompileItemUrls<NewsItem>(item);

                //publish item
                manager.Publish(item);
                manager.SaveChanges();
                */
                #endregion

                #region Fluent API

                //Fluent API version

                Guid itemID = Guid.Empty;
                //App.WorkWith is important helps to create all kinds of things
                App.WorkWith().NewsItem().CreateNew()
                    .Do(newsItem =>
                    {
                        itemID = newsItem.Id;
                        newsItem.Title = "Fluent News Content";
                        newsItem.DateCreated = DateTime.UtcNow;
                        newsItem.PublicationDate = DateTime.UtcNow.AddDays(1);
                        newsItem.ExpirationDate = DateTime.UtcNow.AddDays(30);
                        newsItem.Author = "Jason McIntosh";
                        newsItem.Content = "<h1>New News Story From The Normal API</h1>";
                    })
                    //Publish the item, and save changes
                    //Without publish it's saved as a draft
                        .Publish()
                        .SaveChanges();

                #endregion
            }

  3. Jason
    Jason avatar
    10 posts
    Registered:
    08 Feb 2012
    15 Feb 2012
    Link to this post
    My Sitefinity dashboard and VS pages are pointing to different port numbers. I don't think this is an issue but not sure how to trouble shoot.

    I'm still able to create a content item, but not a page or a blog through VS API code.
  4. Grace Hallwachs
    Grace Hallwachs avatar
    144 posts
    Registered:
    03 Nov 2014
    20 Feb 2012
    Link to this post
    Hi,

    Please reference your other forum post "Unable to "Create" through the API." 

    Please let us know if you have anymore questions.

    Kind regards,
    Grace Hallwachs
    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
4 posts, 0 answered