Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding
Announcements
We are currently migrating data within this board to improve the community. During this process, posting, replying, editing and other features are temporarily disabled. We sincerely apologize for any inconvenience caused and appreciate your understanding. Thank you for your patience and support.

Entitlement Revit API - My update

Julian.Wandzilak
Advocate Advocate
326 Views
0 Replies
Message 1 of 1

Entitlement Revit API - My update

Julian.Wandzilak
Advocate
Advocate

Hello All,

I am recently updating all my paid apps to 2025 - Thanks to this forum, everything goes rather smooth. Except I had some weird problems with my CheckOnline method which was based on provided method here: https://adndevblog.typepad.com/aec/2015/04/entitlement-api-for-revit-exchange-store-apps.html

 

For some reason in 2025 I had some problems with RestSharp -> while checking the licence during OnApplicationInitialized method, the process was abruptly stopped, weirdly enough, without even throwing errors on me.

 

Update helped but as RestSharp change I started having problems with older revit versions. I decided to rewrite it completely, but this time using default HttpClient:

 

public static bool CheckOnline(string appId, string userId)
{
    Uri uri = new Uri($"https://apps.exchange.autodesk.com/webservices/checkentitlement/?userid={userId}&appid={appId}");
    bool isValid = false;

    try
    {
        HttpClient myHttpClient = new HttpClient();

        Task<HttpResponseMessage> task = Task.Run(() => myHttpClient.GetAsync(uri));
        task.Wait();
        HttpResponseMessage response = task.Result;

        Task<string> readTask = response.Content.ReadAsStringAsync();
        string text = readTask.Result;

        EntitlementResponse entitlementResponse = JsonConvert.DeserializeObject<EntitlementResponse>(text);

        isValid = entitlementResponse.IsValid;
    }
    catch
    {
        return false;
    }

    return isValid;
}

[Serializable]
public class EntitlementResponse
{
    public string UserId { get; set; }
    public string AppId { get; set; }
    public bool IsValid { get; set; }
    public string Message { get; set; }
}

 

Here is the code. I hope it might be useful to someone. Works for me in 2020 - 2025

blog: w7k.pl more about me: Linkedin Profile
My add-ins for Revit: Drafter(180+ scripts) & Leveler
Reply
Reply
327 Views
0 Replies
Replies (0)