Skip to main content
1-Visitor
August 4, 2015
Solved

Problems with permissions on custom service

  • August 4, 2015
  • 5 replies
  • 3774 views

I've created a service for creating new Things based on the unbound Remote Things. I've an external SDK agent running this service with a Thing called "MyConnector".

At first I tried this manually with the "Test" button in services tab and it worked fine.

Then I added an applicationKey running as my administrator user and used it to connect new Things to the TWX, and when "MyConnector" was running this service, it created them as it should.

I then tried to create an external user to be used for this application with the applicationKey but I keep getting this error from "MyConnector" Thing:

Reason: Unable to dispatch [ uri = /Things/MyConnector/Services/CreateUnboundRemoteThings/]: Unable to Invoke Service CreateUnboundRemoteThings on MyConnector : Execution error in service script [MyConnector CreateUnboundRemoteThings] : Wrapped com.thingworx.common.exceptions.InvalidRequestException: Not authorized for Create Cause: Not authorized for Create

Here's my CreateUnboundRemoteThings service from MyTestThingTemplate:

var newRemoteThings=Resources["DeviceFunctions"].GetUnboundRemoteThings({maxItems:undefined});

var result=Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({InfoTableName:"CreatedThings",dataShapeName:"NewThingsDataShape"});

for (var i=0;i<newRemoteThings.length;i++){

  Resources["EntityServices"].CreateThing({thingTemplateName:"MyTestThingTemplate",description:undefined,name:newRemoteThings.name});

  Things[newRemoteThings.name].EnableThing();

  Things[newRemoteThings.name].RestartThing();

  result.AddRow({ThingName:newRemoteThings.name});

}

I've added that user permissions for:

  • DeviceFunctions -> GetUnboundRemoteThings service
  • InfoTableFunctions -> CreateInfoTableFromDataShape service
  • EntityServices -> CreateThing service
  • MyTestThingTemplate -> RestartThing and EnableThing services
  • Full permissions on MyConnector Thing
  • Full permissions on NewThingsDataShape

Any idea what permissions am I missing? I've been stuck with this permission problem most of today and can't figure out what I'm missing. At some point I also added that user full design time and run time permissions on DeviceFunctions, InfoTableFunctions, EntityServices, MyTestThingTemplate, "MyConnector" Thing and NewThingDataShape but didn't work even then.

Is the problem due to the fact that my service is local and not remote service (you can't insert script to remote service) ?

Why does it work with my Administrator account then?

Best answer by paic

Looks like the User/Group needs permission to Things/Create in the Design Time permissions of Things

5 replies

paic1-VisitorAnswer
1-Visitor
August 4, 2015

Looks like the User/Group needs permission to Things/Create in the Design Time permissions of Things

miikkae1-VisitorAuthor
1-Visitor
August 5, 2015

I tried giving Design Time Create permissions for both MyTestThingTemplate and MyConnector Thing but still getting the same error.
Is there some global Things/Create permission for all Things or did you mean one of these?