5 Replies Latest reply on Jan 17, 2018 11:30 AM by miikkae RSS
    miikkae Explorer

    Problems with permissions on custom service

    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++){


    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?