cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

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

miikkae
1-Visitor

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.

ACCEPTED SOLUTION

Accepted Solutions
miikkae
1-Visitor
(To:jeff11)

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!

View solution in original post

2 REPLIES 2
jeff11
5-Regular Member
(To:miikkae)

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

miikkae
1-Visitor
(To:jeff11)

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!

Announcements


Top Tags