Skip to main content
16-Pearl
April 16, 2021
Solved

Error on Create Thing service, when accessed via postman

  • April 16, 2021
  • 1 reply
  • 2098 views

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";
}

 

Best answer by DavorGranic

Giving collective permissions to user made it work. Permissions on template or service were not enough it seems. 

1 reply

5-Regular Member
April 16, 2021

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. 

16-Pearl
April 16, 2021

DavorGranic_0-1618580816269.png

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.

 

DavorGranic16-PearlAuthorAnswer
16-Pearl
April 20, 2021

Giving collective permissions to user made it work. Permissions on template or service were not enough it seems.