API Questions on Kentico API.
Version 6.x > API > Can't update document. Throws "No user specified. You must initialize the UserInfo property of the tree provider." error View modes: 
User avatar
Member
Member
jheavner-ce - 7/9/2012 3:26:16 PM
   
Can't update document. Throws "No user specified. You must initialize the UserInfo property of the tree provider." error
Can someone tell me why the following code won't work? I've verified the the UserInfo object is not null but it still throws "No user specified. You must initialize the UserInfo property of the tree provider."


UserInfo ui = UserInfoProvider.GetUserInfo("administrator");
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider(ui);
string aliasPath = String.Format("/Events-and-Awards/Events");
CMS.TreeEngine.TreeNode sessionNode = tree.SelectSingleNode("CorporateSite", aliasPath, "en-us");
sessionNode.SetValue("Title", aiSession.Title);
sessionNode.SetValue("Code", aiSession.Code);
sessionNode.SetValue("description", aiSession.SessionDescription);
sessionNode.Update();

User avatar
Kentico Support
Kentico Support
kentico_radekm2 - 7/10/2012 1:23:24 AM
   
RE:Can't update document. Throws "No user specified. You must initialize the UserInfo property of the tree provider." error
Hello.

Could you please debug it and check if the UserInfo object is properly initialized? API example for document update can be found at http://devnet.kentico.com/docs/5_5R2/devguide/update_document.htm.

Best Regards,
Radek Macalik

User avatar
Member
Member
jheavner-ce - 7/10/2012 3:43:02 PM
   
RE:Can't update document. Throws "No user specified. You must initialize the UserInfo property of the tree provider." error
In my initial post I stated that I verified the UserInfo object was no null. I did that by examining the value in the debugger.

User avatar
Kentico Support
Kentico Support
kentico_radekm2 - 7/13/2012 5:12:30 AM
   
RE:Can't update document. Throws "No user specified. You must initialize the UserInfo property of the tree provider." error
Hello.

I have checked the source code directly. The only event when this error message is raised is if a given user is null, or her ID is 0:

/// <summary>
/// Checks the presence of the user.
/// </summary>
public void CheckUser()
{
// Check if User info set
if ((UserInfo == null) || (UserInfo.UserID == 0))
{
throw new Exception("[TreeProvider.CheckUser]: No user specified. You must initialize the UserInfo property of the tree provider.");
}
}


Could you please send me screenshot from debug showing this UserInfo object? Thank you.

Best Regards,
Radek Macalik