CQL issue cqlcontext

Hi,
I’m using forge UI and I’m getting stuck on a simple CQL query.
It does not seem to filter by spacekey. What am I missing?

  const myLabels = ["typea", "typeb", "typec"];

  async function getPages(label) {
    const cqlSearch = `cqlcontext={"spaceKey":"${context.spaceKey}"}&cql=label=${label}&limit=100`;
    const response = await api
      .asApp()
      .requestConfluence(`/wiki/rest/api/content/search?${cqlSearch}`, {
        headers: {
          Accept: "application/json",
        },
      });

Thanks

Matteo

Have you tried URLEncoding the cqlSearch variable? I found that passing " and {} causes problems.

Hi, yes, but I got the same results.

Anyway, through trials and errors I found that this format works fine:

    const cqlSearch = `cql=label=${label} AND space=${context.spaceKey}&limit=100`;
    const response = await api
      .asApp()
      .requestConfluence(`/wiki/rest/api/content/search?${cqlSearch}`, {
        headers: {
          Accept: "application/json",
        },
      });

Not sure why… but it works fine.