change subaccount's parent_account with api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi. I want to change a subaccount's parent account (parent account is another sub-account). My code:
const CANVAS_TOKEN = process.env.CANVAS_ADMIN_TOKEN;
const data = {
account: {
name: updatedName,
parent_account_id: newParentId
}
}
console.log(data);
const response = await axios.put(CANVAS_API_URL, data, {
headers: {
Authorization: `Bearer ${CANVAS_TOKEN}`,
'Content-Type': 'application/json'
},
});
console.log(response.data);
output:
{ account: { name: 'Beşiktaş Şubesi', parent_account_id: '122' } }
{
id: 128,
root_account_id: 1,
parent_account_id: 115,
name: 'Beşiktaş Şubesi',
workflow_state: 'active',
uuid: '7YE66ureWOaTqtsOk92i14gyZg8kETU3honOcGGl',
default_storage_quota_mb: 500,
default_user_storage_quota_mb: 50,
default_group_storage_quota_mb: 50,
default_time_zone: 'Europe/Istanbul',
sis_account_id: null,
sis_import_id: null,
integration_id: null
}
{ account: { name: 'Beşiktaş Şubesi', parent_account_id: '122' } }
{
id: 128,
root_account_id: 1,
parent_account_id: 115,
name: 'Beşiktaş Şubesi',
workflow_state: 'active',
uuid: '7YE66ureWOaTqtsOk92i14gyZg8kETU3honOcGGl',
default_storage_quota_mb: 500,
default_user_storage_quota_mb: 50,
default_group_storage_quota_mb: 50,
default_time_zone: 'Europe/Istanbul',
sis_account_id: null,
sis_import_id: null,
integration_id: null
}
Even when I set parent_account_id
as an integer, it still doesn't work. The code doesn't throw an error, but it doesn't change the parent_account_id
. It keeps printing the old one.
api that I use: https://canvas.instructure.com/doc/api/accounts.html#method.accounts.update