searchContentByCQL method

Future<ContentArray> searchContentByCQL({
  1. required String cql,
  2. String? cqlcontext,
  3. List<String>? expand,
  4. String? cursor,
  5. int? limit,
})

Returns the list of content that matches a Confluence Query Language (CQL) query. For information on CQL, see: Advanced searching using CQL.

Example initial call:

/wiki/rest/api/content/search?cql=type=page&limit=25

Example response:

{
  "results": [
    { ... },
    { ... },
    ...
    { ... }
  ],
  "limit": 25,
  "size": 25,
  ...
  "_links": {
    "base": "<url>",
    "context": "<url>",
    "next":
"/rest/api/content/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg",
    "self": "<url>"
  }
}

When additional results are available, returns next and prev URLs to retrieve them in subsequent calls. The URLs each contain a cursor that points to the appropriate set of results. Use limit to specify the number of results returned in each call. Example subsequent call (taken from example response):

/wiki/rest/api/content/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg

The response to this will have a prev URL similar to the next in the example response.

Permissions required: Permission to access the Confluence site ('Can use' global permission). Only content that the user has permission to view will be returned.

Implementation

Future<ContentArray> searchContentByCQL(
    {required String cql,
    String? cqlcontext,
    List<String>? expand,
    String? cursor,
    int? limit}) async {
  return ContentArray.fromJson(await _client.send(
    'get',
    'wiki/rest/api/content/search',
    queryParameters: {
      'cql': cql,
      if (cqlcontext != null) 'cqlcontext': cqlcontext,
      if (expand != null) 'expand': expand.map((e) => e).join(','),
      if (cursor != null) 'cursor': cursor,
      if (limit != null) 'limit': '$limit',
    },
  ));
}