Forge Async API 401 Confluence REST API

When I query the Confluence REST API it returns a 401 response

const response = await api.asUser().requestConfluence(route`/wiki/api/v2/spaces`, {
        headers: {
            'Accept': 'application/json'
        }
    });

I know I have the correct scopes set as this works in the backend function, however in the consumer function it doesn’t seem to be sending the oauth token as a parameter.

Does anyone know if this is possible in a queue consumer?

Hello Nahi!

When you are processing an async event, there is no user associated with the request, even if the event was pushed from a user-driven interaction.

Therefore you should use asApp instead of asUser when calling Confluence.

1 Like