Entitlement API - Trouble for a First Timer

Entitlement API - Trouble for a First Timer

retug_austin
Enthusiast Enthusiast
526 Views
5 Replies
Message 1 of 6

Entitlement API - Trouble for a First Timer

retug_austin
Enthusiast
Enthusiast

This is my first time trying to publish an app to the app store and I am trying to follow the documentation for utilizing the Entitlement API service. https://adndevblog.typepad.com/aec/2015/04/entitlement-api-for-revit-exchange-store-apps.html and https://damassets.autodesk.net/content/dam/autodesk/www/adn/pdf/entitlement-api-for-desktop-apps.pdf

 

My problem lies in these lines of code:

client.BaseUrl = new System.Uri(_baseApiUrl);

JsonDeserializer deserial = new JsonDeserializer();

I get an error at client.BaseUrl, "RestClient" does not contain a definition for 'BaseUrl' are you missing a directory?

Also, the sample using statement is using RestSharp.Deserializers; but RestSharp appears to no longer have this? It does have RestSharp.Serializers;

 

I have downloaded and installed RestSharp v110.2.0.0

austinguter_0-1705589467821.png

I have placed the sample code on github.

https://github.com/retug/RevitAddins

 

Can you point out where I have gone wrong?

 

Thanks!

0 Likes
Accepted solutions (1)
527 Views
5 Replies
Replies (5)
Message 2 of 6

ricaun
Advisor
Advisor
Accepted solution

Probably is the version of the RestSharp that is different from the code sample.

 

I created this sample that does not require the RestSharp, only the Newtonsoft.Json that already exists inside Revit.

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 3 of 6

retug_austin
Enthusiast
Enthusiast

Thanks Ricaun, this works, appreciate it!

I piecemealed some chatgpt together to use this CheckLicenseValidity function

 

        public MainWindow(UIDocument UiDoc )
        {
            uidoc = UiDoc;

            doc = UiDoc.Document;

            Title = "R2R Panel";
            InitializeComponent();
            // Set the window icon dynamically
            SetWindowIcon();
            bool IsLicenseActive = false;
            CheckLicenseValidity(ref IsLicenseActive)
}       

 private void CheckLicenseValidity(ref bool IsLicneseActive)
        {
            var appid = "86934581652450005802"; // Replace with your app ID
            var userid = uidoc.Application.Application.LoginUserId;
            var appEntitlement = new AppEntitlement(appid);

            var entitlementResponse = appEntitlement.GetEntitlement(userid);
            IsLicneseActive = entitlementResponse.IsValid;
            if (entitlementResponse != null)
            {
                var text = "AppId: " + entitlementResponse.AppId + "\n";
                text += "UserId: " + entitlementResponse.UserId + "\n";
                text += "IsValid: " + entitlementResponse.IsValid + "\n";
                text += "Message: " + entitlementResponse.Message;

                // Do something with the entitlement information, e.g., display in a dialog
                TaskDialog.Show("AppEntitlement", text);
            }
            else
            {
                // Handle the case when the response is null
                TaskDialog.Show("AppEntitlement", "License validation failed");
            }
        }

 

The function appears to work and outputs false IsValid entitlementResponse, so I guess it is working.

Is this how you handle this as well? Seems a bit "not-dry" in terms of coding, as I have to re-input appid and userid given that it is defined in the code you reference, but I couldn't get a "drier" version of the code to work.

 

Also, I assume that when you submit the app to the Autodesk app store, they will issue you your appid?

 

Thanks!

0 Likes
Message 4 of 6

ricaun
Advisor
Advisor

The LoginUserId is defined depending on what account is connected inside Revit and you gonna receive an ID when you create an app in the Autodesk AppStore.

 

The 8693458165245000580 is for my first plugin the EasyConduit. https://apps.autodesk.com/RVT/en/Detail/Index?id=8693458165245000580

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 5 of 6

BimDoers
Participant
Participant

@ricaun 
I have similar issue but the wired matter is that it works for revit versions 2020\2022\2023\2024 and not only 2021 !!!

do you have any clue what is that about ?


0 Likes
Message 6 of 6

michaelGBVEK
Observer
Observer

@ricaun This was extremely helpful and easy to implement with a few minor changes to fit in my project. Thank you very much for this updated method over what is in the documentation!