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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

UpdatePropertyValues usage via the API (Thingworx Service)

NiKlaus
12-Amethyst

UpdatePropertyValues usage via the API (Thingworx Service)

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

ACCEPTED SOLUTION

Accepted Solutions

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

 

 

View solution in original post

7 REPLIES 7
Yedukrishnan
14-Alexandrite
(To:NiKlaus)

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

 

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. 
 



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

 

 

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

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.

 

It works fine, however the response is still nothing. 
Not sure if it is the thingworx version that I am using. 

NiKlaus
12-Amethyst
(To:NiKlaus)

Hi @Sathishkumar_C it seems to be working on all of my other properties except for one. I am not sure why the one propery is not updateding. I duplicated and deleted the old one and it is working fine. 
Thank you for the help. 

Announcements


Top Tags