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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to use QueryNamedPropertyHistory service with API call

aseaton
7-Bedrock

How to use QueryNamedPropertyHistory service with API call

Hi community,

I've been trying to use the service; QueryNamedPropertyHistory() through an API call but not having any success. These are the details of my call:

Method: POST

Url: http://xx-xxx-xxx-xxx/Thingworx/Things/ThingName/Services/QueryNamedPropertyHistory?appKey==xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx…

Body:

params = {

      "oldestFirst": false,

      "maxItems": 50,

      "endDate": null,

      "startDate": null,

      "query": null,

      "propertyNames" : {

      "rows": [{

          "name": "propertyName",

          "description": "propertyDescription"

      }],

      "dataShape": {

          "fieldDefinitions": {

              "name": {

                  "name": "name",

                  "aspects": {},

                  "description": "",

                  "baseType": "STRING",

                  "ordinal": 1

              },

              "description": {

                  "name": "description",

                  "aspects": {},

                  "description": "",

                  "baseType": "STRING",

                  "ordinal": 2

              }

          }

      }

  }

}

Below is my response: I would expect to see the propertyName in the response data alongside the 'timestamp' field. Does anyone have any advice?

QueryNamedPropertyHistory Response pic.PNG

Thanks

Andy

4 REPLIES 4
aseaton
7-Bedrock
(To:aseaton)

I see that the query parameter works when it is written out, for example:

query param json.PNG

...but i havent had success with a null query...any help appreciated.

Andy

aseaton
7-Bedrock
(To:aseaton)

jamesm1
5-Regular Member
(To:aseaton)

You do not need to define params in the JSON body; this is working for me:

curl -X POST \

  http://localhost/Thingworx/Things/TestQueryThing/Services/QueryNamedPropertyHistory \

  -H 'accept: application/json' \

  -H 'appkey: ' \

  -H 'cache-control: no-cache' \

  -H 'content-type: application/json' \

  -H 'postman-token: 607288b1-b9c4-f9c4-bc3b-1bbe2f49cda6' \

  -d '{

   "maxItems":2,

   "propertyNames":{

      "dataShape":{

         "fieldDefinitions":{

            "name":{

               "name":"name",

               "baseType":"STRING",

               "ordinal":0

            }

         }

      },

      "rows":[

         {

            "name":"test"

         }

      ]

   }

}'

aseaton
7-Bedrock
(To:jamesm1)

Thanks James for your reply. I found success with the following example request body:

QueryNamedPropertyHistory params with Query.PNG

Andy

Top Tags