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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

REST API giving 500 Internal Errors when setting property

tk512
4-Participant

REST API giving 500 Internal Errors when setting property

I am setting the temperature property on a Thing, and intermittently getting 500 Internal Errors.

curl -v -X PUT -H 'appKey: 119710c2-d13f-4986-9bde-dfe359327a26' -d '{ "temperature": 55 }' -H 'Accept: application/json' -H "Content-Type: application/json" "http://localhost:8080/Thingworx/Things/MyThing/Properties/temperature

About 10% of the time I get 200 OK result and the property gets set properly, but mostly I get 500 Internal Error.

I think this must be a TW bug? Running ThingWorx 8.1.2-b51 at the moment.

 

The log complains about [context: com.thingworx.webservices.context.HttpExecutionContext@722b9f2d]  in the http-nio-8080-exec-5 thread.  I don't see any stack traces, even in catalina.out in Tomcat.

 

Aside from this, the Thingworx installation is working just fine in terms of Composer and so on.

 

However this problem is keeping us from actually using our IoT assets to set the property values. So we urgently need help with this.

 

ApplicationLog below.  It's odd that the more use of the mashup(s) using this Thing (just normal GetPropertyValues stuff), the higher the chance to get a 500.

2018-03-29 13:39:06.017+0200 [L: DEBUG] [O: c.t.p.PersistenceProviderTransactionManager] [I: ] [U: sams] [S: ] [T: http-nio-8080-exec-11] ***ending transaction level 0***
2018-03-29 13:39:06.018+0200 [L: DEBUG] [O: c.t.p.ThingworxDefaultTransaction] [I: ] [U: sams] [S: ] [T: http-nio-8080-exec-11] ***committing transaction***
2018-03-29 13:39:09.761+0200 [L: DEBUG] [O: c.t.s.a.ApplicationKey] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-18] Application key sams-app-key is valid.
2018-03-29 13:39:09.761+0200 [L: DEBUG] [O: c.t.s.s.i.SubscriptionStoreInMemoryThreadSafe] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-18] There are no listeners for publisher GenericThing
2018-03-29 13:39:09.761+0200 [L: DEBUG] [O: c.t.s.s.i.SubscriptionStoreInMemoryThreadSafe] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-18] There are no listeners for publisher SecurityMonitor
2018-03-29 13:39:09.762+0200 [L: DEBUG] [O: c.t.s.s.i.SubscriptionStoreInMemoryThreadSafe] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-18] There are no listeners for publisher SecurityMonitor
2018-03-29 13:39:09.762+0200 [L: DEBUG] [O: c.t.s.s.i.SubscriptionStoreInMemoryThreadSafe] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-18] There are no subscribers for event Type.Thing:Entity.SecurityMonitor:Event.ApplicationKeySucceeded
2018-03-29 13:39:09.762+0200 [L: DEBUG] [O: c.t.w.BaseService] [I: ] [U: sams] [S: ] [T: http-nio-8080-exec-18] Executing request [URI: /Thingworx/Things/MyThing/Properties/temperature]
2018-03-29 13:39:09.762+0200 [L: DEBUG] [O: c.t.w.c.HttpExecutionContext] [I: ] [U: sams] [S: ] [T: http-nio-8080-exec-18] { "temperature": 13.1 }
2018-03-29 13:39:09.763+0200 [L: DEBUG] [O: c.t.p.PersistenceProviderTransactionManager] [I: ] [U: sams] [S: ] [T: http-nio-8080-exec-18] ***Creating top level scope for transaction***
2018-03-29 13:39:09.765+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: sams] [S: ] [T: http-nio-8080-exec-18] [context: com.thingworx.webservices.context.HttpExecutionContext@3593905c]
2018-03-29 13:39:09.766+0200 [L: DEBUG] [O: c.t.p.p.StreamEntryProcessor] [I: ] [U: SuperUser] [S: ] [T: pool-13-thread-12] Stream Entry Max Wait Time Reached...
2018-03-29 13:39:09.767+0200 [L: DEBUG] [O: c.t.p.p.StreamEntryProcessor] [I: ] [U: SuperUser] [S: ] [T: pool-13-thread-12] Processing 1 Stream Entries on Thread 142
2018-03-29 13:39:09.767+0200 [L: DEBUG] [O: c.t.p.PersistenceProviderTransactionManager] [I: ] [U: SuperUser] [S: ] [T: pool-13-thread-12] ***Creating top level scope for transaction***
2018-03-29 13:39:09.767+0200 [L: DEBUG] [O: c.t.p.p.PersistentPropertyDataProcessor] [I: ] [U: SuperUser] [S: ] [T: pool-13-thread-12] Persisted properties dedupped by 0%
2018-03-29 13:39:09.767+0200 [L: DEBUG] [O: c.t.p.PersistenceProviderTransactionManager] [I: ] [U: SuperUser] [S: ] [T: pool-13-thread-12] ***Created transaction from ThingworxPersistenceProvider ***
2018-03-29 13:39:09.770+0200 [L: DEBUG] [O: c.t.p.p.DefaultStreamEntryProcessor] [I: ] [U: SuperUser] [S: ] [T: pool-13-thread-12] Local Processing Of 1 Stream Entries on Thread 142 took 3053332 nanoseconds
2018-03-29 13:39:09.770+0200 [L: DEBUG] [O: c.t.p.ThingworxDefaultTransaction] [I: ] [U: SuperUser] [S: ] [T: pool-13-thread-12] ***committing transaction***
2018-03-29 13:39:10.952+0200 [L: DEBUG] [O: c.t.s.a.Authenticator] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-9] This request is a Confirm Credentials action: false
2018-03-29 13:39:10.953+0200 [L: DEBUG] [O: c.t.s.a.Authenticator] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-9] This request is a Change Password action: false
2018-03-29 13:39:10.954+0200 [L: DEBUG] [O: c.t.s.a.Authenticator] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-9] This request is a password action related: false
2018-03-29 13:39:10.954+0200 [L: DEBUG] [O: c.t.s.a.Authenticator] [I: ] [U: ] [S: ] [T: http-nio-8080-exec-9] This request is a login action: false
1 ACCEPTED SOLUTION

Accepted Solutions
tk512
4-Participant
(To:Rick-Stanley)

The Persistence Provider did not have Visibility to my organization - which caused random 500's.  Very strange that it worked partly.  But that is the fix - i.e. to ensure correct permissions for the Persistence Provider (the built-in one in my case).

View solution in original post

3 REPLIES 3
PaiChung
22-Sapphire I
(To:tk512)

Did you submit a support ticket for this already?

Also have you tried with without temperature at the end of the URL so it just ends in Properties?

or conversely { 'value' : 45 }

I can't see anything necessarily wrong, unless you are 'over running' the server with writes or events.

What Thing Template is your Thing "MyThing" based on? If it is a real device in the field it might seem logical to use the  RemoteThing Template, but you should use the GenericThing Template for devices that connect using the REST API. Only use the RemoteThing Template for Things that connect to ThingWorx using the AlwaysOn protocol. 

tk512
4-Participant
(To:Rick-Stanley)

The Persistence Provider did not have Visibility to my organization - which caused random 500's.  Very strange that it worked partly.  But that is the fix - i.e. to ensure correct permissions for the Persistence Provider (the built-in one in my case).

Top Tags