Retrieving issues via search rest API (cloud) with specific property that is not empty

Hi everyone,

I need to count the total number of issues that have a specific property not empty via API REST (cloud).

So when searching for the issues with my specific property, for example:

rest/api/2/search?jql=project=10001&fields=*none&maxResults=-1&properties=com.a.b.c.PANEL_DATA-12345

I get the list of all issues (even the ones that have empty object in this property:

{
    "expand": "schema,names",
    "startAt": 0,
    "maxResults": 100,
    "total": 2,
    "issues": [
        {
            "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
            "id": "10004",
            "self": "https://jira-cloud-abc.atlassian.net/rest/api/3/issue/10004",
            "key": "DI-4",
            "properties": {
                "com.a.b.c.PANEL_DATA-12345": {
                    "pluginVersion": "1.1-SNAPSHOT",
                    "platform": "cloud",
                    "zippedContent": "UEsDBAoAAAAIAO2ERE6g..."
                }
            }
        },
        {
            "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
            "id": "10002",
            "self": "https://jira-cloud-abc.atlassian.net/rest/api/3/issue/10002",
            "key": "DI-2",
            "properties": {}
        }
    ]
}

(as you can see the second issue appears in the results with empty properties and this affects the total number of issues which is set to 2.

Is there a way to simply have in the response only the issues that actually have something in the structure of the property that I am searching (on order to have the real total calculated to 1)? Or I will need to parse all the issues from the response manually in order to count the real total number of the issues?

Thank you

Hi, @dusan.spaic,

Do you have a Connect app?

You can add a property extraction (using the entity property module) that would make the property searchable in JQL. Then you would be able to write a query to return only issues with that property set:

issue.extractedProperty is not empty

In the REST API you can get only count, without the issues, by sending the maxResults query param equal to 0. If you do that, the response will contain only page meta-data, including the total count.

Hope this helps.

1 Like

Hi @kkercz ,

Thank you for your reply.
Adding a property extraction in my atlassian-connect.json is not an option since the property key that I am setting in the issue property is not static.

And thanks a lot for the maxResults=0 tip, it helps reduce the response.

Dusan