Can't create News Item through API, get You are not authorized to 'Create {0}' ('General').
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.
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
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.
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