Error when consuming Kentico API from external WebAPI 2 project

Victor Hugo Garcia asked on June 26, 2015 05:05

Hello friends,

I'm trying to consume the Kentico API 8.2 from an external project following the best practices from K8 official documentation and it is just awesome. However when trying to retrieve information using DocumentHelper, I found an issue that is not letting me continue with the project.

I'm getting the following error: Method is only supported if the user name parameter matches the user name in the current Windows Identity.

See screenshot below for further reference and stack trace:

Image Text

The code that I'm trying to use is:

UserInfo user = UserInfoProvider.GetUserInfo("public");
using (new CMSActionContext(user))
            {
               var docs = DocumentHelper.GetDocuments()
                    .Type(className, q =>
                        q.Columns("CustomName","CustomAddress")
                    )
                    .Columns("DocumentID")
                    .OnSite(siteName)
                    .Select(i => new Location{
                        Name = ValidationHelper.GetString(i["CustomName"],""),
                        Address = ValidationHelper.GetString(i["CustomAddress"],"")
                     })
                     .ToList();

                return docs;
            }

Note: I added all Dlls as mentioned in the documentation.

Any help is always welcome.

Thanks in advance

   Please, sign in to be able to submit a new answer.