Using UI Kit REST call to route`/wiki/api/v2/pages/${contentId}/children - was working before, now returns 401

I had removed this REST from my project for a while (trying to accomplish the same with search instead). When I added this REST call back in, I now get a 401. Is there something I need to reset?

const getPageChildrenSorted = async (contentId) =>{
  const response = await api.asUser().requestConfluence(route`/wiki/api/v2/pages/${contentId}/children?limit=100`);  //&sort=childPosition
  if(!response.ok){
    const err = `Error while requesting /wiki/api/v2/pages/${contentId}/children: ${response.status} ${response.statusText}`;
    console.error(err);
    throw new Error(err);
  }

  const result = await response.json();
  return result;
};

scopes in manifest:

permissions:
  scopes:
    - read:page:confluence
    - search:confluence

Error:

Something went wrong

There was an error invoking the function - Error while requesting /wiki/api/v2/pages/33138/children: 401 Unauthorized

Error: Error while requesting /wiki/api/v2/pages/33138/children: 401 Unauthorized
    at getPageChildrenSorted (index.js:41391:11)

Uninstalling and reinstalling the app seemed to fix this.

1 Like