I want to grant a user access to a restricted confluence cloud page. I used the (Documentation) Add user to content restriction for reference. But I am getting an error 401 (Unathorized)
export const grantPageAccess = async (pageId, accountId, operation) => {
try {
const response = await api.asUser()
.requestConfluence(route`/wiki/rest/api/content/37703334532/restriction/byOperation/update/user/?accountId=12333523452452452`, {
method: 'PUT',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
});
console.log(response);
return response.status === 200;
} catch (error) {
console.log(`Error granting page restriction: ${error.message}`);
return false;
}
};
Note: I hardcoded the pageId, account, and operation for testing purposes. My token is valid, I have permissions to grant access to the restricted content. This works when testing with Insomnia and Postman