Skip to main content
Dec 12, 2019 7:51 PM UTC
Solved

REST API - Filter Example

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

RaduAnswer
Dec 13, 2019 7:04 AM UTC

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.

 

3 replies

Dec 12, 2019 11:37 PM UTC

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?

vieirac1Author
Dec 13, 2019 1:01 AM UTC
Hi,

Tks and should I use GetImplementedthingswithdata or queryimplementedthingswithdata?

What is the main difference?

Tks

Chris Vieira
RaduAnswer
Dec 13, 2019 7:04 AM UTC

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.