How to use a custom query filter in JAVA SDK

Product/components used and version/fix level:

Cumulocity Production

Detailed explanation of the problem:

Hi, I have a class called CustomQueryParam which returns a instance of custom query filter. I have tried this with others and it works perfectly fine, so i was wondering if I can similarly use a custom query filter in this way.


import com.cumulocity.sdk.client.Param;
import com.cumulocity.sdk.client.QueryParam;

public class CustomQueryParam extends QueryParam {
    private static final Param QUERY_PARAM = new Param() {
        public String getName() {
            return "creationTime";

    private static final CustomQueryParam INSTANCE = new CustomQueryParam();

    public static CustomQueryParam getInstance() {
        return INSTANCE;
    private CustomQueryParam() {
        super(QUERY_PARAM, " ge "+CustomUtil.getDateWithTime());

Now I am calling this in my inventory filter call like this:

InventoryFilter deviceFilter = new InventoryFilter().byFragmentType("c8y_IsDevice");
Iterable<ManagedObjectRepresentation> mObjColl = inventoryApi.getManagedObjectsByFilter(deviceFilter).get(2000, CustomQueryParam.getInstance()).allPages();

But i am getting this exception:

Caused by: com.cumulocity.sdk.client.SDKException: Illegal characters used in URL.

Can you please tell me how can I achieve this?

Best Regards,

Hi Samanyu,

even I have never worked with C8Y, I will try to sort it out a little bit:

Most likely the issue is with the line “super(QUERY_PARAM, …);”, the second parameter might be causing this issue here.
Can you please check if the syntax of the “query=…” part is correct?
When this gets appended to URL after a question mark, it is not allowed to contain any blanks as this will break the URL.


Can you do a quick check and URL encode the custom query part using

1 Like

Hi Holger,

The syntax is correct, I first tried it in postman then only I tried with SDK. Is there any way I can see the url anywhere. I can do getSelf() but it is failing at .get(2000,).

Thanks & Regards,

With adding logging.level.root=DEBUG to your you’ll get a verbose output - including the URLs sent to the platform. Or you can set a breakpoint and debug the URL in your IDE.