cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Error on Create Thing service, when accessed via postman

DavorGranic
16-Pearl

Error on Create Thing service, when accessed via postman

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

 

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

3 REPLIES 3

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. 

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.

 

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

Announcements


Top Tags