Entitlement API - user hasEntitlement returning false, then returns true on the 2nd or 3rd try.

Entitlement API - user hasEntitlement returning false, then returns true on the 2nd or 3rd try.

Maltezc
Advocate Advocate
469 Views
2 Replies
Message 1 of 3

Entitlement API - user hasEntitlement returning false, then returns true on the 2nd or 3rd try.

Maltezc
Advocate
Advocate

Hi all, I have a couple of apps on the app store and for one of them, when I try to use it, I get an error saying I don't have entitlement. However, it will work on the 2nd or 3rd try. 

 

Has this been happening for anyone else?

 

Is this an error on Autodesk's side?

 

Is there anything I can do besides trying the entitlement method again?

0 Likes
470 Views
2 Replies
Replies (2)
Message 2 of 3

Sean_Page
Collaborator
Collaborator

Have you checked to make sure that whatever Flag you are using to allow the app to run is being properly set on the first run? Sounds like the Autodesk portion of the entitlement is working because you get the result you want eventually.

 

Have you put the complete URL directly into a browser to see if you get the intended result every time?

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 3 of 3

Maltezc
Advocate
Advocate

I just did as you suggested and tried the URL in a browser as you suggested and the same thing happens.

here is my code: 

 

my flag: 

string userId = rvtApp.LoginUserId;
            bool isValid = verifyEntitlement(_appId, userId);

            if (isValid)
            {
                // my code begins here; 
             }

 

private bool verifyEntitlement(string appId, string userId)
        {
            //REST API call for the entitlement API.
            //We are using RestSharp for simplicity.
            //You may choose to use another library.

            //(1) Build request
            var client = new RestClient();
            client.BaseUrl = new System.Uri(_baseApiUrl);


            //Set resource/end point
            var request = new RestRequest();
            request.Resource = "webservices/checkentitlement";
            request.Method = Method.GET;

            //Add parameters
            request.AddParameter("userid", userId);
            request.AddParameter("appid", appId);

            //(2) Execute request and get response
            IRestResponse response = client.Execute(request);


            // Get the entitlement status.
            // (3) Parse the response and get the value of IsValid.
            bool isValid = false;
            if (response.StatusCode == HttpStatusCode.OK) 
            {
                JsonDeserializer deserial = new JsonDeserializer();
                EntitlementResponse entitlementResponse = deserial.Deserialize<EntitlementResponse>(response);
                isValid = entitlementResponse.IsValid;
            }

            return isValid;
        }

 

 

I get the same ratio working and not working. roughly 1 out of 3 give or take. 

 

I get this page when it doesn't work

 

Screen Shot 2021-05-11 at 3.14.35 PM.png

and then I get this page when it does work. 

 

 

Screen Shot 2021-05-11 at 3.16.23 PM.png

 

 

 

0 Likes