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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

REST API property value update do not fire value change event

jbester
14-Alexandrite

REST API property value update do not fire value change event

Good day,

I am updating a property value on a thing using the REST API. The property value is successfully updated on the Thing (the value changes when viewed under properties), but no value change event is picked up to be logged to a value stream or fire a subscription on value change.

In the Application logs, the following error message is showed: [context: com.thingworx.webservices.context.HttpExecutionContext@301db274].

Any suggestions as to what possibly the problem is?

Thank you

ACCEPTED SOLUTION

Accepted Solutions
smanley
14-Alexandrite
(To:jbester)

It seems like the data change event is not firing because the user does not have permission to add the logged properties to the value stream. With stack tracing enabled in the logging subsystem, you will see an error like this.

com.thingworx.webservices.context.HttpExecutionContext@5fc32268] java.lang.NullPointerException: null

    at com.thingworx.persistence.common.ValueStreamEngine.getValueStreamEntryProcessor

This can be corrected by adding the organization that your user belongs to to the visibility permissions of the Thingworx persistence provider. To update this, from the persistence provider list, select "advanced" and check "Show System Objects" to display the ThingWorxPersistenceProvider. Add your organization in the visibility section and save.

View solution in original post

8 REPLIES 8
ytella
17-Peridot
(To:jbester)

Hi Johan Bester, Could you please confirm the way you have followed to create an event for the thing ?

Did you create a custom event on the thing as shown below?

or Defined the events at the thing, thing template or thing shape level?

jbester
14-Alexandrite
(To:ytella)

Hi Yamini,

Thank you for the reply.

Neither. I was expecting the built-in data change occurrence when a value is changed to happen. It does fire and log the value to the value stream to be found under QueryPropertyHistory when I change it manually in the system, but when the property value is updated using the REST API it changes the value but does not get stored in the value stream.

ytella
17-Peridot
(To:jbester)

Hi Johan Bester,

Thank you for the information.

I will try to reproduce the issue in my local instance and will get back to you as soon as I can. I would also like a copy of your entities for testing on my instance. I would highly appreciate it if you can provide them.

jbester
14-Alexandrite
(To:jbester)

Update:

It seems to be a permission error. It works fine if I change the Application Key I use to have Administrative access instead of limited access to only change the one thing.

I assume there are some visibility permissions I have to set on one of the subsystems or resources to get it to function properly.

Does anybody have any idea which one it is? I have tried:

     - Platform subsystem

     - Logging subsystem    

     - ValueStreamProcessingSubsystem

to no avail.

Thank you

posipova
20-Turquoise
(To:jbester)

Do you have property update permissions on the thing? Visibility on the thing and its template too.

jbester
14-Alexandrite
(To:posipova)

Hi Polina,

I do have the visibility, design time as well as runtime permissions set up on the thing instance, not on the Generic template thing template it is derived from, but I do not think it is necessary because it is one instantiation of the specific thing I am working with. (To make sure it is not the issue I just gave all of the visibility and design time and run time permissions to specific user on all of the templates and things and it did not make a difference).

Without the proper permissions on the thing I do not think the property can be updated from the REST API which it is doing. It just do not pick up a value change to write it to the value stream or fire a subscription on data change.

I have set the visibility and permissions on the subsystems and the resources to include the specific limited rights user that the application key use, still getting the same error message with no event triggered. So it doesn's even look like the issue is there.

I am out of other possible ideas for the moment, do you perhaps have some? I do not think it is an option to give the remote device reporting the data Administrative privileges.

(just a quick description of my setup: at the moment I have a test Thing set up inheriting from the GenericThing template, I have a value stream assigned to the thing and all the relevant visibilities and permissions for runtime and design time set. I have two properties (a test value being changed (logged) via PUT request and a boolean property changing with a subscription on data change of the test property). The value for test property is updated with the API and I can see the value change, but subscription is not fired and the logged test property is not logged to value stream when the application key has reduced permissions, but when the application key has Administrative privileges it works without an issue)

Your help is appreciated.

smanley
14-Alexandrite
(To:jbester)

Hi Johan,


I assume the error message you posted is from the Application log, but if you are observing the data change issue by checking the execution of a subscription, you should see more information in the script log each time a subscription script execution is attempted. Can you send a copy of the script log as well as a screen shot of the runtime permissions of the Thing entity?

smanley
14-Alexandrite
(To:jbester)

It seems like the data change event is not firing because the user does not have permission to add the logged properties to the value stream. With stack tracing enabled in the logging subsystem, you will see an error like this.

com.thingworx.webservices.context.HttpExecutionContext@5fc32268] java.lang.NullPointerException: null

    at com.thingworx.persistence.common.ValueStreamEngine.getValueStreamEntryProcessor

This can be corrected by adding the organization that your user belongs to to the visibility permissions of the Thingworx persistence provider. To update this, from the persistence provider list, select "advanced" and check "Show System Objects" to display the ThingWorxPersistenceProvider. Add your organization in the visibility section and save.

Announcements


Top Tags