<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Entitlement Revit API - My update in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/entitlement-revit-api-my-update/m-p/12761235#M5393</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;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 &lt;STRONG&gt;&lt;SPAN&gt;CheckOnline&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt; &lt;SPAN&gt;method which was based on provided method here: &lt;A href="https://adndevblog.typepad.com/aec/2015/04/entitlement-api-for-revit-exchange-store-apps.html" target="_blank"&gt;https://adndevblog.typepad.com/aec/2015/04/entitlement-api-for-revit-exchange-store-apps.html&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;For some reason in 2025 I had some problems with RestSharp -&amp;gt; while checking the licence during OnApplicationInitialized method, the process was abruptly stopped, weirdly enough, without even throwing errors on me.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public static bool CheckOnline(string appId, string userId)
{
    Uri uri = new Uri($"https://apps.exchange.autodesk.com/webservices/checkentitlement/?userid={userId}&amp;amp;appid={appId}");
    bool isValid = false;

    try
    {
        HttpClient myHttpClient = new HttpClient();

        Task&amp;lt;HttpResponseMessage&amp;gt; task = Task.Run(() =&amp;gt; myHttpClient.GetAsync(uri));
        task.Wait();
        HttpResponseMessage response = task.Result;

        Task&amp;lt;string&amp;gt; readTask = response.Content.ReadAsStringAsync();
        string text = readTask.Result;

        EntitlementResponse entitlementResponse = JsonConvert.DeserializeObject&amp;lt;EntitlementResponse&amp;gt;(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; }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Here is the code. I hope it might be useful to someone. Works for me in 2020 - 2025&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2024 20:07:29 GMT</pubDate>
    <dc:creator>Julian.Wandzilak</dc:creator>
    <dc:date>2024-05-08T20:07:29Z</dc:date>
    <item>
      <title>Entitlement Revit API - My update</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/entitlement-revit-api-my-update/m-p/12761235#M5393</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;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 &lt;STRONG&gt;&lt;SPAN&gt;CheckOnline&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt; &lt;SPAN&gt;method which was based on provided method here: &lt;A href="https://adndevblog.typepad.com/aec/2015/04/entitlement-api-for-revit-exchange-store-apps.html" target="_blank"&gt;https://adndevblog.typepad.com/aec/2015/04/entitlement-api-for-revit-exchange-store-apps.html&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;For some reason in 2025 I had some problems with RestSharp -&amp;gt; while checking the licence during OnApplicationInitialized method, the process was abruptly stopped, weirdly enough, without even throwing errors on me.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public static bool CheckOnline(string appId, string userId)
{
    Uri uri = new Uri($"https://apps.exchange.autodesk.com/webservices/checkentitlement/?userid={userId}&amp;amp;appid={appId}");
    bool isValid = false;

    try
    {
        HttpClient myHttpClient = new HttpClient();

        Task&amp;lt;HttpResponseMessage&amp;gt; task = Task.Run(() =&amp;gt; myHttpClient.GetAsync(uri));
        task.Wait();
        HttpResponseMessage response = task.Result;

        Task&amp;lt;string&amp;gt; readTask = response.Content.ReadAsStringAsync();
        string text = readTask.Result;

        EntitlementResponse entitlementResponse = JsonConvert.DeserializeObject&amp;lt;EntitlementResponse&amp;gt;(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; }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Here is the code. I hope it might be useful to someone. Works for me in 2020 - 2025&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 20:07:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/entitlement-revit-api-my-update/m-p/12761235#M5393</guid>
      <dc:creator>Julian.Wandzilak</dc:creator>
      <dc:date>2024-05-08T20:07:29Z</dc:date>
    </item>
  </channel>
</rss>

