# Create a Measurement filter

**URL:** <https://community.cumulocity.com/t/create-a-measurement-filter/3967>\
**Category:** Forum\
**Tags:** microservice, cumulocity\
**Created:** [February 1, 2024, 10:56am UTC](https://community.cumulocity.com/t/create-a-measurement-filter/3967 "2024-02-01T10:56:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkpatil1010](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jkpatil1010](https://community.cumulocity.com/u/jkpatil1010)\
**Post date:** [February 1, 2024, 10:56am UTC](https://community.cumulocity.com/t/create-a-measurement-filter/3967/1 "2024-02-01T10:56:13Z")

</div>

Hi,

I have Api :  
[https://xyz/measurement/measurements/series/?source=123&dateFrom=2024-02-01T00:00:00.000Z&dateTo=2024-02-01T23:00:00.000Z&pageSize=1440&revert=true&series=fragmentName.seriesname](https://xyz/measurement/measurements/series/?source=123&dateFrom=2024-02-01T00:00:00.000Z&dateTo=2024-02-01T23:00:00.000Z&pageSize=1440&revert=true&series=fragmentName.seriesname)

need to call Above this using MeasurementApi.  
Format the above Api as below example.

Example: final MeasurementFilter filter = new MeasurementFilter().bySource(new GId(deviceId)).byType(fragment).byDate(oneHourBack.toDate(), currentTime.toDate());

please reply with the MeasurementFilter for above mentioned Api

---

<div class="post-metadata">

**Author:** ![Stefan\_Witschel](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/stefan_witschel/32/31955_2.png) [@Stefan\_Witschel](https://community.cumulocity.com/u/Stefan_Witschel)\
**Post date:** [February 6, 2024, 10:09am UTC](https://community.cumulocity.com/t/create-a-measurement-filter/3967/2 "2024-02-06T10:09:40Z")

</div>

Have you checked out the doc? Not all of the REST API supported filter are supported in the SDK unfortunately.

> **[MeasurementFilter (Cumulocity SDK - Java Client API)](https://resources.cumulocity.com/documentation/javasdk/current/com/cumulocity/sdk/client/measurement/MeasurementFilter.html)**
>
> declaration: package: com.cumulocity.sdk.client.measurement, class: MeasurementFilter

Beside that you can add non-supported query params by implementing them yourself, roughly described here (e.g. extending the existing filter etc.)

> [@Best-Practices to use the Microservice SDK for Java for custom API queries](https://community.cumulocity.com/t/best-practices-to-use-the-microservice-sdk-for-java-for-custom-api-queries/7177):
>
> Introduction The Cumulocity IoT API provides a wide range of API query capabilities, but only a subset is easily useable directly by the Microservice SDK for Java. Mostly the inventory API provides the most capable (and complex) [query language](https://cumulocity.com/api/core/#tag/Query-language), which is heavily used in many projects. Also other APIs like alarm, event, measurement, audit and identity also can be used with the same approach! Due to the wide variety of features, query language and URL parameters, the SDK does not support this i…

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [August 4, 2024, 10:09am UTC](https://community.cumulocity.com/t/create-a-measurement-filter/3967/3 "2024-08-04T10:09:47Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
