401 Unauthorized "Get content in space with given content state"

I am attempting call this Confluence Cloud REST API from a Forge resolver:

This should allow me to get the content in a space what has a particular Content Status. End user documentation is here:

This call is in the v1 API but I can not find an equivalent in the v2 one. Is there a better approach?

My manifest.yml contains this scope :

    - read:confluence-content.all

I have also tried the more granular read:content:confluence and both at the same time. The behaviour is the same; I always get a 401 Unauthorized status.

My resolver looks like this:

import Resolver from '@forge/resolver';
import api, { route } from "@forge/api";

const resolver = new Resolver();

resolver.define('getContentForState', async (req) => {


  if (!'spaceKey' in req.payload) {
    return null;

  const spaceKey = req.payload.spaceKey;
  const status = req.payload.status;

  if (typeof(spaceKey) === 'undefined') {
    return null;

  console.log('getContentForState: %s %s', spaceKey, status);

  try {
    const requestUrl = route`/wiki/rest/api/space/${spaceKey}/state/content?state-id=${status}`;

    // Make a request to the Confluence REST API to fetch content state settings
    const response = await api.asUser().requestConfluence(requestUrl);

    if (response.status === 200) {
      // If the request is successful, return the content state settings
      const contentForStatus = await response.json();
      return contentForStatus.results;
    } else {
      // If the request is not successful, handle the error
      console.error(`Failed to fetch content for state: ${response.status} ${response.statusText}`);
      return null;
  } catch (error) {
    // Catch any unexpected errors
    console.error('Error fetching content for state:', error);
    return null;


export const handler = resolver.getDefinitions();

In the forge tunnel output I can see:

INFO    13:22:25.200  89d7472a-[redacted]  getContentForState()
INFO    13:22:25.200  89d7472a-[redacted]  getContentForState: BD 65044485
INFO    13:22:25.200  89d7472a-[redacted]  /wiki/rest/api/space/BD/state/content?state-id=65044485
ERROR   13:22:25.276  89d7472a-[redacted]  Failed to fetch content for state: 401 Unauthorized

If I take the the URL displayed and prepend the instance URL, I get the expected REST API call results. This seems to prove that the REST API exists and that the user account has the required access to it.

What am I doing wrong?