I’ve been wrestling with CQL for a while now, time to ask for help.
Whatever I do (see below) I always get the same 400
response
com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not parse cql
These are the docs I’ve read (due to the limit on 2 links for new users I’m cutting the urls)
- modules/content-property
- modules/content-property-index-key-configuration
- connect-app-descriptor
- confluence-entity-properties/#cql-search-extension
- advanced-searching-using-cql
plus this How to define Index schema for content properties through REST API thread
I added the confluenceContentProperties
module to my descriptor
"confluenceContentProperties": [
{
"name": {
"value": "My props"
},
"key": "myaddon-my-props", <- this is not in any of the docs, but installation fails without it
"keyConfigurations": [
{
"propertyKey": "all-my-addon-props",
"extractions": [
{
"objectName": "prop1",
"alias": "my-addon-prop1",
"type": "string"
},
{
"objectName": "prop2",
"alias": "my-addon-prop2",
"type": "string"
},
{
"objectName": "prop3",
"alias": "my-addon-prop3",
"type": "string"
}
]
}
]
}
]
I’m adding the properties at the same as I create a page with the /rest/api/content
endpoint
"metadata": {"properties": {"all-my-addon-props": {"prop1": "foo", "prop2": "bar", "prop3": "baz"}}}
and I can verify it worked correctly by querying the properties endpoint
https://<MY DOMAIN>.atlassian.net/wiki/rest/api/content/<PAGE ID>/property
Additionally, I can issue simple CQL queries and expand the metadata to prove it’s there e.g.
https://<MY DOMAIN>.atlassian.net/wiki/rest/api/content/search?cql=space=<MY SPACE>&expand=metadata.properties.all-my-addon-props
Now the stuff that does not work:
According to developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/
I should be able to get the pages containing prop1 = foo
with
https://<MY DOMAIN>.atlassian.net/wiki/rest/api/content/search?cql=content.properties%5Ball-my-addon-props%5D.prop1%3Dfoo
But this returns status 400 com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not parse cql
.
So I notice that content
is not in the expandable
list when doing the simple space=..
query, and that properties is actually inside metadata
so I try that instead
https://<MY DOMAIN>.atlassian.net/wiki/rest/api/content/search?cql=metadata.properties%5Ball-my-addon-props%5D.prop1%3Dfoo
But I get the same 400 error as above.
The docs also mention the use of aliases, so I try that
https://<MY DOMAIN>.atlassian.net/wiki/rest/api/content/search?cql=my-addon-prop1%3Dfoo
But again I get the same 400 error.
So what is going on? AFAIK the descriptor is correct and matches the docs I linked above.