Hello,
We use the LucidChart macro in multiple pages. I am trying to use CURL with CQL to output a list of occurrences, but it isn't working.
This is what I am trying:
curl -u MyUsername:MyPassword "https://MyCompany.com/rest/api/content/search?cql=(space=Public+macro="LucidChart")" -o "C:\Output.txt"
Output.txt is generated, but just contains one line which includes 'cannot parse cql'.
Any advice appreciated.
Thanks,
Adrian
@Adrian Morse
If you look at the cURL examples on the Confluence Search Content page, it should be fairly obvious where you've used the wrong bracket type for delimiting the CQL within the URL
It sounds like you are suggesting that I replace the brackets with curly brackets. I just tried that and it still didn't work...
"Could not parse cql : space=Public macro=LucidChart","reason":"Bad Request"}
In contrast, if I run this command below (which does have non-curly brackets btw) the operation is successful:
curl -u user:password “https://MyCompany.com/rest/api/content/search?cql=(space=Public%20and%20type%=%20page%20and%20text%20~%20TEST)&limit=1000" -o “C:\Output.txt”
No, what I meant was, there shouldn't be any brackets around the CQL statement; straight, curly or otherwise. CQL statments are all just declared directly in the URL, like this:
https://MyCompany.com/wiki/rest/api/content/search?cql=space=Public and macro="LucidChart" and other=other&whateverelse=whateverelse
The REST API knows that the first equals sign after the identifier 'jql' is the first delimiter and it assumes everything that follows is part of the CQL statement until an ampersand is found, or the end of the URL is reached.
Also, plus signs '+' are not a valid CQL operators. The operator is 'and' preceded and followed by a space, as per my example above and as per your second example.
The only reason your second example worked, the one that was inside some parentheses, was that you accidentally created a valid precedence.
As per the CQL documentation:
Setting precedence of operatorsTo enforce the precedence of operators, you can use parentheses in complex CQL statements.For example, if you want to find all pages in the Developer space as well as all blog posts created by the the system administrator (bobsmith), you can use parentheses to enforce the precedence of the boolean operators in your query. For example:(type=page and Space=DEV) OR (creator=bobsmith and type=blogpost)Note: if you do not use parentheses, the statement will be evaluated left to right.
To enforce the precedence of operators, you can use parentheses in complex CQL statements.
For example, if you want to find all pages in the Developer space as well as all blog posts created by the the system administrator (bobsmith), you can use parentheses to enforce the precedence of the boolean operators in your query. For example:
(type=page and Space=DEV) OR (creator=bobsmith and type=blogpost)
Note: if you do not use parentheses, the statement will be evaluated left to right.
It looks like you're new here. Sign in or register to get started.