Hi Lily and thank you for your reply. The code you posted adds Run Time Instance Permissions, i.e. permissions that get inherited to the Things that are created from the Thing Template. However, what I want to do is to add Run Time Permissions to the Thing Template itself (and, later, also to other types of entities such as Thing Shapes, Data Shapes, Mashups, etc.).
As below screenshots shows, the properties and Events are empty. It means we couldn't grant ThingTemplate/ThingShape any run time permission that related to property and event.
ThingTemplate/ThingShape don't have specific values for properties and events, that why you can only grant the PropertyRead and PropertyWrite with Run Time Instance.
The reason why you can grant service execute is because ThingTemplete/ThingShape has some service that will be executed on their own entity like GetImplementingThings, GetImplementingThingsWithData...
As a conclusation, ThingTemplate/ThingShape AddRunTimePermission service only can grant service exectue permission.
Any concern, just let me know.
ThingTemplate are not property providers they just hold the definitions .Template's do not store any data .Thus the correct service as mentioned in the above reply is AddInstanceRunTimePermission instead of AddRunTimePermission . This service will through the error as mentioned by you when you will execute it on Template .Template do not hold actual values ,they are for defining the metadata .
If you are in a use case of using this service on Template then give details about the use case .But this is how it should work .