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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

REST API: How to get the multiple entries of a property while firing the URL?

sv
1-Visitor
1-Visitor

REST API: How to get the multiple entries of a property while firing the URL?

Hi,

I want to get the multiple entries of a properties by passing the URL.

For eg: When i pass the URL " ge2-****.cloud.thingworx.com/Thingworx/Things/Trucks/Properties?method=get&Accept=application/json "

I should get the following result:

{"iot":[                                      // When i fired, Its showing "rows", I want it to be "iot"

{

    "ID": "1",

    "TruckID": "T101",

    "PalletID": "P101",

    "TransitTime": "10:02:01",

    "CurrentLoc": "Kochi",

    "Health": "Good",

    "Source": "Trivandrum",

    "Destination": "Mumbai",

     "Shipper": "EY",

    "Remarks": "Asset valuable",

     "Action": "Action"

},

{

    "ID": "2",

    "TruckID": "T101",

    "PalletID": "P102",

    "TransitTime": "10:02:01",

    "CurrentLoc": "Kochi",

    "Health": "Good",

    "Source": "Trivandrum",

    "Destination": "Mumbai",

     "Shipper": "EY",

    "Remarks": "Asset valuable",

     "Action": "Action"

},

]}

ACCEPTED SOLUTION

Accepted Solutions
dmoon
12-Amethyst
(To:sv)

I am not sure if I understood correctly or not, but I guess you might want to get properties with values for "Trucks" in your ThingWorx platform, not just from one truck, right?

If yes, you might have defined a thing template for trucks. Then you can get all implementing things with data from the thing template by using below rest api.

ge2-****.cloud.thingworx.com/Thingworx/ThingTemplates/PTC.Demo.Assets.MRIMachineTemplate/Services/GetImplementingThingsWithData?method=post&Accept=application/json

One thing you have to remember is that the "post" method is not enabled by default because of security issues. So if you want to execute services thru rest apis, please make "Allow Request Method Switch" enabled from the "PlatformSubsystem" in your composer.

Daniel

View solution in original post

5 REPLIES 5
dmoon
12-Amethyst
(To:sv)

I am not sure if I understood correctly or not, but I guess you might want to get properties with values for "Trucks" in your ThingWorx platform, not just from one truck, right?

If yes, you might have defined a thing template for trucks. Then you can get all implementing things with data from the thing template by using below rest api.

ge2-****.cloud.thingworx.com/Thingworx/ThingTemplates/PTC.Demo.Assets.MRIMachineTemplate/Services/GetImplementingThingsWithData?method=post&Accept=application/json

One thing you have to remember is that the "post" method is not enabled by default because of security issues. So if you want to execute services thru rest apis, please make "Allow Request Method Switch" enabled from the "PlatformSubsystem" in your composer.

Daniel

sv
1-Visitor
1-Visitor
(To:dmoon)

Thank you daniel!

I also tried getting using:

http://**-****.cloud.thingworx.com/Thingworx/Things/<Thingname>/Services/QueryPropertyHistory?method=post

I am getting the required output.

sv
1-Visitor
1-Visitor
(To:dmoon)

But this method is for listing the things. What i asked was i want to get logged values of a property.

dmoon
12-Amethyst
(To:sv)

If you want to get all the logged values for each things, you should use the "QueryPropertyHistory" or other queries based on your condition that you want to get recursively by using the name of all implementing things from the "GetImplementingThings" result.

ttielebein
14-Alexandrite
(To:sv)

Hello,

You can use the REST API to get properties off of a thing like this: http://localhost/Thingworx/Things/MyThing/Properties

To retrieve this as JSON, add "?Accept=application/json" to the end of the previous link

Hope this helps!

Tori

Announcements


Top Tags