Skip to main content
12-Amethyst
December 19, 2023
Solved

UpdatePropertyValues usage via the API (Thingworx Service)

  • December 19, 2023
  • 2 replies
  • 2195 views

I am looking to update multiple properties by making use of the service UpdatePropertyValues but I don't seem to be getting it right. 

I am using python to post my data and I get a 200 response back but the values are not actually updating when I use the service QueryNumberPropertyHistory. 
This is the URL that I am trying to access: 
url = "http://localhost/Thingworx/Things/Area_Thing5/Services/UpdatePropertyValues
I have also tried: 
url = "http://localhost/Thingworx/Things/Area_Thing5/services/UpdatePropertyValues"  

and i still get a 200 ok response, which makes it unclear which url is actually correct. 
my Payload looks something like this: 
{"name":"Item_Count", "value":1112, "timestamp":1702976380000, "quality":"GOOD"}

And then I post it with a content type application/json 

 

I have also tried with a payload: {"name":"Item_Count", "value":1112, "time":1702976380000, "quality":"GOOD"}

Best answer by Sathishkumar_C

Created thing "Demo" and property "speed" (INTEGER)

http://localhost:8080/Thingworx/Things/Demo/Services/UpdatePropertyValues?ts=1702991337784

1702991337784 - Refers UNIX Timestamp

Following payload data will be used to update speed proprty to 10.

{
 "values": {
 "dataShape": {
 "fieldDefinitions": {
 "name": {
 "name": "name",
 "aspects": {
 "isPrimaryKey": true
 },
 "description": "Property name",
 "baseType": "STRING",
 "ordinal": 0
 },
 "time": {
 "name": "time",
 "aspects": {},
 "description": "time",
 "baseType": "DATETIME",
 "ordinal": 0
 },
 "value": {
 "name": "value",
 "aspects": {},
 "description": "value",
 "baseType": "VARIANT",
 "ordinal": 0
 },
 "quality": {
 "name": "quality",
 "aspects": {},
 "description": "quality",
 "baseType": "STRING",
 "ordinal": 0
 }
 }
 },
 "rows": [
 {
 "name": "speed",
 "time": "2023-12-18T18:30:00.000Z",
 "value": "10",
 "quality": "GOOD"
 }
 ]
 }
}

 

 

2 replies

14-Alexandrite
December 19, 2023

Hi @NiKlaus ,

 

Please check if the property is getting updated. 

 

To log the incoming data, you have to assign valuestream to the thing. The service "QueryNumberPropertyHistory" will only fetch data if value stream is assigned to the thing and  log is enabled for the property "Item_Count".

Yedukrishnan_0-1702984703632.png

Please give more details, if not solved.

 

With regards

Yedukrishnan

 

NiKlaus12-AmethystAuthor
12-Amethyst
December 19, 2023

Hi @Yedukrishnan Yes the property is set to persist and logged. 
I am able to see the property history after using the following API: 

Payload: {"Item_count": 12}
Using the put method. 
What other information would you need to assist? I am very new to thingworx so I am unsure at this point. 
 
So when I QueryNumberHistory, I do see a history of values but when I use the :UpdatePropertyValues service, i do not see the values in the value stream. 
 



17-Peridot
December 19, 2023

Created thing "Demo" and property "speed" (INTEGER)

http://localhost:8080/Thingworx/Things/Demo/Services/UpdatePropertyValues?ts=1702991337784

1702991337784 - Refers UNIX Timestamp

Following payload data will be used to update speed proprty to 10.

{
 "values": {
 "dataShape": {
 "fieldDefinitions": {
 "name": {
 "name": "name",
 "aspects": {
 "isPrimaryKey": true
 },
 "description": "Property name",
 "baseType": "STRING",
 "ordinal": 0
 },
 "time": {
 "name": "time",
 "aspects": {},
 "description": "time",
 "baseType": "DATETIME",
 "ordinal": 0
 },
 "value": {
 "name": "value",
 "aspects": {},
 "description": "value",
 "baseType": "VARIANT",
 "ordinal": 0
 },
 "quality": {
 "name": "quality",
 "aspects": {},
 "description": "quality",
 "baseType": "STRING",
 "ordinal": 0
 }
 }
 },
 "rows": [
 {
 "name": "speed",
 "time": "2023-12-18T18:30:00.000Z",
 "value": "10",
 "quality": "GOOD"
 }
 ]
 }
}

 

 

NiKlaus12-AmethystAuthor
12-Amethyst
December 19, 2023

Hi @Sathishkumar_C thank you for your response. 
I have done the following: 
curl --location 'http://localhost/Thingworx/Things/Area_Thing5/Services/UpdatePropertyValues?ts=1702937532012' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'AppKey: ####' \
--data '{
"values": {
"dataShape": {
"fieldDefinitions": {
"name": {
"name": "name",
"aspects": {
"isPrimaryKey": true
},
"description": "Property name",
"baseType": "STRING",
"ordinal": 0
},
"time": {
"name": "time",
"aspects": {},
"description": "time",
"baseType": "DATETIME",
"ordinal": 0
},
"value": {
"name": "value",
"aspects": {},
"description": "value",
"baseType": "VARIANT",
"ordinal": 0
},
"quality": {
"name": "quality",
"aspects": {},
"description": "quality",
"baseType": "STRING",
"ordinal": 0
}
}
},
"rows": [
{
"name": "VSM_Count",
"time": "2023-12-19T12:12:12.012Z",
"value": "9999",
"quality": "GOOD"
}
]
}
}'

My response is blank: 

NB_10856218_0-1702992703778.pngNB_10856218_1-1702992729926.png

And still nothing in the value stream. 
Hoping you can help further

17-Peridot
December 19, 2023

Response should be 1.

Sathishkumar_C_0-1702993773427.png

  • Are you able to see value in property?
  • Other options also you can try.... Create custom service with 1 input... and update from the custom server.