Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
I have simple create Thing service that works fine when I test it in Thingworx.
But when trigered via postman it returns error:
"TypeError: Cannot call method "CreateThing" of null"
Permissions seem not to be the problem. Im guessing its something simple but im stumped.
If anyone has an idea it would be greatly appreciated.
Service code:
var nameThing="TestThing";
try
{
params = {
name: nameThing,
description: "This Is A New Thing",
thingTemplateName: "GenericThing",
projectName:'PMI Demo',
};
Resources["EntityServices"].CreateThing(params);
Things[nameThing].EnableThing();
Things[nameThing].RestartThing();
result="Ok";
}
catch (err) {
result="Not Ok";
}
Solved! Go to Solution.
Giving collective permissions to user made it work. Permissions on template or service were not enough it seems.
if you are sure that the app key(user) which is passed when you execute this via Postman does have permission to execute this service on ThingWorx, then it should be something in your Postman request itself. I hope you are doing a POST call on the endpoint like https://host:port/Thingworx/Things/TestThing/Service/YourServiceName.
I tried the same snippet posted by you in the question and I am able to call it from Postman as well. If possible share what you are sending via postman.
I can trigger other services but only this one with create thing wont work.
Seems that thing that gets created has no permissions needed for that user to restart it in service.
It creates thing(when I start it with admin user in Thingworx) but not with needed permissions.
Giving collective permissions to user made it work. Permissions on template or service were not enough it seems.