2 Replies Latest reply on Oct 14, 2015 4:29 AM by miikkae RSS
    miikkae Explorer

    Getting error with .NET SDK while everything seems to be running smoothly

    I'm trying to connect an analytics camera to ThingWorx via .NET SDK.

    I have a single static Thing in ThingWorx that is used to run a service for detecting new unbound Remote Things and creating those Things. That works as intended and I can manually remove a camera Thing and it appears back to ThingWorx on next run.

    After that service run, the analytics from cameras (detected events etc) are being processed through another services and put in infotable properties as defined in the ThingTemplate.

    These are also getting gathered correctly.

     

    My problem is, that while I run the program, I keep getting these three errors multiple times:

    Unable to dispatch [ uri = /Things/MySDKGateway/Services/GetEventSubscriptions/]: Unable to Invoke Service GetEventSubscriptions on MySDKGateway : Not authorized for ServiceInvoke on GetEventSubscriptions in MySDKGateway


    error executing APIRequest Message: Unable to dispatch [ uri = /Things/MySDKGateway/Services/GetEventSubscriptions/]: Unable to Invoke Service GetEventSubscriptions on MySDKGateway: Not authorized for ServiceInvoke on GetEventSubscriptions in MySDKGateway, sending ERROR ResponseMessage to caller!

    error executing APIRequest Message: Unable to dispatch [ uri = /Things/MySDKGateway/Services/GetPropertySubscriptions/]: Unable to Invoke Service GetPropertySubscriptions on MySDKGateway: Not authorized for ServiceInvoke on GetPropertySubscriptions in MySDKGateway, sending ERROR ResponseMessage to caller!

    The services shouldn't be using any service called "GetEventSubscriptions" or "GetPropertySubscriptions" and I haven't event found one called that.

    Also tried to giving the application key user the full permissions on the ThingTemplate for both run time and run time instance for Event Subscribe and Service Execute but didn't have any effect.

    If I don't use ConnectedThingClient.SetAsSDKType() method, it gives the same errors for some other Thing. If I use it all (or at least all I checked) the errors are specified to that SDKGateway thing.

     

    Any idea where these errors are coming from and what permissions I should give the user?

     

    Otherwise everything seems to be working as planned but the problem's that the error logs fill the capacity from ThingWorx server quite rapidly when the program's running and I have no clue why.

      • Re: Getting error with .NET SDK while everything seems to be running smoothly
        jeff Explorer

        The services in question are being called by the Subscribed Property Manager within the SDK. The GetEventSubscription and GetPropertySubscription services are not visible at the composer level, but you can add runtime or design time permissions to these services using the AddRunTimePermission or AddDesignTimePermission service calls. The following javascript example could be used in a service call on the thing in question to add runtime permissions for the subscribed property manager related services:

         

        var params = {

          principal: "TestUser" /* STRING */,

          allow: true /* BOOLEAN */,

          principalType: "User" /* STRING */,

          resource: "GetEventSubscriptions" /* STRING */,

          type: "ServiceInvoke" /* STRING */

        };

        me.AddRunTimePermission(params);

         

        var params = {

          principal: "TestUser" /* STRING */,

          allow: true /* BOOLEAN */,

          principalType: "User" /* STRING */,

          resource: "GetPropertySubscriptions" /* STRING */,

          type: "ServiceInvoke" /* STRING */

        };

        me.AddRunTimePermission(params);

          • Re: Getting error with .NET SDK while everything seems to be running smoothly
            miikkae Explorer

            In this case, is the Thing in question MySDKGateway? So I'll have to create the according Thing to give the permissions?

            I'm gonna try to do that with full runtime permissions for Event Subscribe and Service Execute with MySDKGateway.

             

            EDIT:

            Ok, tried with your scripts. While calling that service via SDK, I got an error and while I used those manually, they had no effect. I replaced the "TestUser" with the username that's running the SDK, still got the same errors.

            I also tried creating the MySDKGateway Thing with SDKGateway template and running the same script with that but still got the errors.

            Finally, I just gave the user full permissions for Event Subscribe and Service Execute for

            1) Run Time Instance in the ThingTemplate used

            2) Run Time in MySDKGateway Thing

            and got rid of the errors.

             

            I think I'll keep it this way, at least for now.

             

            Thanks for your help anyway!