Rest api searching for tasks where variable exists

Is there a way to search for tasks where a process variable exists using the rest api?
Right now I am using the post task search described here.
https://docs.camunda.org/manual/latest/reference/rest/task/post-query/

I have it working for process variables that I know exist and I just want a certain value. However, I have a use case where I need all the ones that don’t have the variable and in another case, all the ones that do regardless of the value.

Thanks,
Megan

I think a single api won’t suffice for this. You can use GET /task/{id}/variables/{varName api for each task in the get task list api. That will give you appropriate http status depending upon if that variable exists or not.

thanks, that’s what I have been doing, but was hoping to cut down on the looping and process time as I have lots of processes and lots of variables.

Querying for all tasks that don’t have a specific variable might be impossible with the exisiting filters.
But getting all tasks that have a variable regardless of its value might work, if you know the variable type and that the variable is not null:

{
    "processVariables": [{
        "name":"stringVariable",
        "operator":"like",
        "value":"%"
    }]
}
{
    "processVariables": [{
        "name":"integerVariable",
        "operator":"gteq",
        "value":-2147483648
    }]
}

But I agree, additional filters like hasVariables or notHasVariables for this REST-Endpoint would be nice.

thanks! that’s a great idea. I’m not sure it will satisfy all of my use cases, but definitely some.