randy
randy

Reputation: 275

How do i use the Kenitco API from a Console App

I'm using Kentico V10 and I can run the website locally. However, when i try to use the API from a console app, i'm getting the following error.

{"Object type 'cms.class' not found."}

The stackTrace has a call to check license. I'm following this page, and it says you have to add a license for your domain, but what domain is used when you are running from a console app?

https://docs.kentico.com/k10/integrating-3rd-party-systems/using-the-kentico-api-externally

I'm using this code from taken from this page. https://docs.kentico.com/k10/managing-users/user-registration-and-authentication/configuring-single-sign-on

        CMS.DataEngine.CMSApplication.Init();

        string userName = "myuser";

        // Gets the user with the specified user name
        UserInfo userInfo = UserInfoProvider.GetUserInfo(userName);

        // Gets the authentication URL for a specified user and target URL
        string url = AuthenticationHelper.GetUserAuthenticationUrl(userInfo, "SecuredSurvey");

If that was available via the REST API, i'd be happy to get the URL that way, but from what i can see, it's not available.

-Randy

Upvotes: 0

Views: 474

Answers (1)

Brenden Kehren
Brenden Kehren

Reputation: 6117

Kentico has some good documentation on how to use the API in an external application, specifically a console library here.

Very notable steps are:

  1. Connecting to the database; make sure you use the same connection string as in your web.config
  2. Install the Kentico.Libraries NuGet package
  3. Initialize Kentico in your application in the Global.asax file.
  4. Write custom code all day long.

Upvotes: 0

Related Questions