Skip to main content
1-Visitor
May 30, 2016
Solved

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

  • May 30, 2016
  • 1 reply
  • 3738 views

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"

},

]}

Best answer by dmoon

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

1 reply

dmoon5-Regular MemberAnswer
5-Regular Member
May 31, 2016

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_011-VisitorAuthor
1-Visitor
May 31, 2016

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.