Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Property values are associated with a specific Thing, and are used to store data that changes over time.
<server_ip:port>/Thingworx/Things/<name of Thing>/Services/AddPropertyDefinition
2. Send request parameters.
{ "name" : "SomeNumber", "type" : "NUMBER" }
NOTE: The full request must include a header with the appKey for your specific ThingWorx server.
A successful call to the AddPropertyDefinitionservice does not return any content in the body of the response. Only an HTTP 200 is returned.
http -v -j http://52.201.57.6/Thingworx/Things/SomeTestThing/Services/AddPropertyDefinition appKey==64b879ae-2455-4d8d-b840-5f5541a799ae name=SomeNumber type=NUMBER
WARNING for other HTTP clients: Most HTTP clients do not set a Content-Type header by default, without this header set the server will return an error message. The POST request to the AddPropertyDefinition endpoint has a JSON body so the header must be set to match the format of the request body.
The Content-Type header does not appear in the sample HTTPie call because HTTPie sets the Accept and Content-type request headers to application/json by default. Below is an example cURL call that explicitly sets the Content-Type header to application/json.
curl -v -H "Content-Type: application/json" -X POST -d '{"name": "SomeNumber","type": "NUMBER"}' http://52.201.57.6/Thingworx/Things/SomeTestThing/Services/AddPropertyDefinition?appKey=d0a68eff-2cb4-4327-81ea-7e71e26b
2. Execute RestartThing Service.
<server_ip:port>/Thingworx/Things/<name of Thing>/Services/RestartThing
http -v -j POST http://52.201.57.6/Thingworx/Things/SomeTestThing/Services/RestartThing appKey==64b879ae-2455-4d8d-b840-5f5541a799ae
You can set the value of a specific Property with the REST API using the PUT verb.
Construct the URL.
<server_ip:port>/Thingworx/Things/<name of Thing>/Properties/<name of Property>
2. Send request parameters.
{ "SomeNumber" : 34.4 }
NOTE: The full request must include authentication credentials for your specific ThingWorx server.
A successful call to set a Property does not return any content in the body of the response. Only an HTTP 200 is returned.
http -v -j PUT http://52.201.57.6/Thingworx/Things/SomeTestThing/Properties/SomeNumber appKey==64b879ae-2455-4d8d-b840-5f5541a799ae SomeNumber=34.4
WARNING for other HTTP clients: By default HTTPie sets the Accept and Content-type request headers to application/json. A PUT request to the Properties endpoint has a JSON body so the Content-Type header must be set to match the format of the request body.
Most HTTP clients do not set the correct header by default and it must be set explicitly. Below is an example cURL call that sets the Content-Type header to application/json
curl -v -H "Content-Type: application/json" -X PUT -d '{"SomeNumber":12.34}' http://52.201.57.6/Thingworx/Things/SomeTestThing/Properties/SomeNumber?appKey=d0a68eff-2cb4-4327-81ea-7e71e26b
To confirm your Property was changed for your Thing, go to Composer and click Things. Select the name of the Thing you just created, then click Properties and Alerts tab. Click on the circular arrow Refresh to see the updated Property value.
You can retrieve Property values of a specific Thing with the REST API using the GET verb.
Construct the URL.
<server_ip:port>/Thingworx/Things/<name of Thing>/Properties/<name of property>
Substitute <name of thing> with the actual name of a Thing that exists on the ThingWorx server and <name of Property> with the name of a Property that has been added to the Thing.
NOTE: The full request will also need to include the hostname and authentication credentials for your specific ThingWorx server.
2. Send request parameters. Other than authentication, no other parameters are used in this GET request.
The content can be returned in four different formats by sending an Accept header with the request.
Desired Response Type | Accept Header Values |
JSON | application/json |
XML | text/xml |
HTML | text/html (or omit Accept Header) |
CSV | text/csv |
http -v -j http://52.201.57.6/Thingworx/Things/SomeTestThing/Properties/SomeNumber appKey==64b879ae-2455-4d8d-b840-5f5541a799ae