Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Entitlement API - Invalid JSON from Entitlement Request

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
danny-carmen
1624 Views, 11 Replies

Entitlement API - Invalid JSON from Entitlement Request

Hey everyone,

 

I am a first time plugin developer in the final stages of submitting my plugin to the Store. Currently the issue is that neither I, nor the tester at Autodesk, are getting a valid response from the entitlement server upon request. I have looked into the error, and I am not sure what is going wrong. It looks like there is an error when I try to access the webservices/checkentitlement, it doesn't seem to be finding that URL. I have attached a screenshot of what shows when I examine the response when debugging. The ResponseUri is "https://apps.autodesk.com/Error/ServerError?aspxerrorpath=/webservices/checkentitlement%22". As I am very new to all of this, I basically just copied over the code from the Autodesk Entitlement document and changed the relevant areas. I am using the RestSharp library as Autodesk suggests. The error actually occurs at the "EntitlementResponse entitlementResponse = deserial.Deserialize<EntitlementResponse>(response);" line, when I try to deserialize the response from Autodesk.

My relevant code is below and I have also attached images of the error that I get when opening the plugin and the results when I examine the response during debugging in Visual Studio.

 

public const string _baseApiUrl = @"https://apps.autodesk.com/";
        public const string _appId = @"<my plugin id here, I have checked this multiple time, I don't think this is the issue>";

private bool CheckEntitlement(string appId, string userId)
        {
            
            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);

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

            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; }
        }

 

Thanks in advance for any help, I'm really stumped on this one.

11 REPLIES 11
Message 2 of 12
danny-carmen
in reply to: danny-carmen

After further investigation, this seems to be more than just my plugin. I am using the document "Autodesk App Store: Entitlement API for desktop Apps", which gives a sample request URL of https://apps.autodesk.com/webservices/checkentitlement?userid=2N5FMZW9CCED&appid=2024453975166401172, and when I follow that it leads me to an error page. Interestingly, if I remove the userid and/or the appid value from that URL, I get a valid JSON string. (Example: https://apps.autodesk.com/webservices/checkentitlement?userid=2N5FMZW9CCED&appid= or https://apps.autodesk.com/webservices/checkentitlement?userid=&appid=2024453975166401172) 

 

Is this happening for anyone else? I have tried on multiple devices and networks and it seems to be consistent across the board. Is anyone using the standard Autodesk Entitlement API successfully?

Message 3 of 12
TorsionTools
in reply to: danny-carmen

We experienced almost that exact thing. It resolved once the app was published. I worked with the App team and showed them videos of it working for our other apps that have identical entitlement. Not sure what it's related too exactly but seems to be something on the Autodesk server side.

Message 4 of 12
danny-carmen
in reply to: TorsionTools

Interesting, I’ll see if I can convince the tester to publish it and see if it works. Thank you very much for the help, I'll mark your answer as a solution if it ends up working.

Message 5 of 12

Sorry for the hassle. We have added your email address to the entitlement list of the app. Please check now

Message 6 of 12

Thanks Raghavendra,

 

I did get a bit more information on the process from Sandeep, one of Raghavendra's colleagues. Per his response:

"If the user is not there in the entitlement list then it does throw as an exception.

If the user is there in the entitlement list but entitlement period is expired then it would return ‘FALSE’

If the user is there in the entitlement list but entitlement period is active then it would return ‘TRUE’"

 

So it would seem that outside of the testing environment, if someone has obtained the plugin legitimately through the App Store there shouldn't be any chance of the exception being thrown, but if someone copied the files from another computer they would run into that error. I ended up just adding code to catch the exception if it occurs.

 

Message 7 of 12
Maltezc
in reply to: danny-carmen

Hi there. Thought this might help anyone in the future in regards to app publishing workflow.

 

What I do is I usually start out a tool with a "dummy" app id. For example, I've downloaded a tool so I have entitlement to that tool and then I use its appId (found in the dummy tool's URL) for the duration that my tool is in development. This helps for testing on my machine before I publish an app for review by the app store. 

 

After that, when I'm ready for my tool to get reviewed, I'll publish, and shoot the app store review team an email saying I've submitted "X" app for review and to please add my account for entitlement. 

 

I might be the only person to admit this but there are always bugs and improvements to be made so i'll end up swapping out the appId later.

 

Once that's done and I have entitlement to my own app, I'll swap the "dummy" appId with the new one that has been created for my app on the app store. 

 

Then I'll be able to test my app on my machine with the correct AppId. 

 

Anyways, hope that helps. Best of luck in your endeavors. 

Message 8 of 12
bnewcombe
in reply to: danny-carmen

Same problem seems to have been occuring since that document was published in 2013

add an extra character to app id making it twenty characters long seems to work

https://apps.autodesk.com/webservices/checkentitlement?userid=2N5FMZW9CCED&appid=2202445397516640117...

Message 9 of 12
landis.mark
in reply to: danny-carmen

Has anyone solved this problem? I am trying to implement the Autodesk entitlement without any luck. I get the same error as Danny in his debugging examination. 

Thanks in advance for any help.

 

Message 10 of 12
danny-carmen
in reply to: landis.mark

It has been a bit, so I can’t remember well, but I think someone from Autodesk just had to add the required email to the entitlement, then it worked.

Message 11 of 12
landis.mark
in reply to: danny-carmen

That was correct, Raghavendra fixed this for me. I have finally worked this out.

 

Thanks to all.

Message 12 of 12
esatis
in reply to: bnewcombe

yess! That works! thank you! 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community