Skip to main content
10-Marble
December 12, 2019
Solved

REST API - Filter Example

  • December 12, 2019
  • 1 reply
  • 1920 views

Hi Team,

 

Please, how can we query via REST API, things like in the following scenario:

·    Things are defined with Location and Temperature properties

·    Customer will have an external application to query all Things temperatures from a particular location (filter things by location and retuning only temperature)

 

Tks,

Chris

Best answer by Radu

The difference is that GetImplementingThingsWithData() returns all the Things that are part of the Thing Template that contains your service, whereas QueryImplementingThingsWithData() does the same, but only returns the Things that respect a certain query. More info on how to use queries are found here.

 

If it is not of any help, you can try the first method. You can iterate through all the things returned by GetImplementingThingsWithData() and return only the ones that meet certain criteria.

 

1 reply

15-Moonstone
December 12, 2019

Hi vieirac1,

 

I imagine these Things with Location and Temperate properties share the same Thing Template. If so, you can create a service on the template that interrogates all the implementing Things ( using GetImplementingThingsWithData() ) and checks whether their Location property matches the Location service parameter, returning the temperature if so.

 

Is this the approach you're looking for?

vieirac110-MarbleAuthor
10-Marble
December 13, 2019
Hi,

Tks and should I use GetImplementedthingswithdata or queryimplementedthingswithdata?

What is the main difference?

Tks

Chris Vieira
Radu15-MoonstoneAnswer
15-Moonstone
December 13, 2019

The difference is that GetImplementingThingsWithData() returns all the Things that are part of the Thing Template that contains your service, whereas QueryImplementingThingsWithData() does the same, but only returns the Things that respect a certain query. More info on how to use queries are found here.

 

If it is not of any help, you can try the first method. You can iterate through all the things returned by GetImplementingThingsWithData() and return only the ones that meet certain criteria.