Page creation Program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024
04:37 PM
How can I add custom_params to a page creation function? Here is what I have now, "
// Function to create a new page in the course with an iFrame in the body
async function createCoursePage(courseId, pageTitle) {
const url = `${canvasBaseUrl}/api/v1/courses/${courseId}/pages`;
const data = {
wiki_page: {
title: pageTitle,
body: ['external_tool'],
external_tool_tag_attributes: {
new_tab: false,
custom: {
resource_id:'l_6f490902-a7fb-481f-af0a-36a238bfbfde_787c18c2-9824-4ac3-afb8-c4cac9c8436d',
}
}
};
try {
const response = await axios.post(url, data, {
headers: { 'Authorization': `Bearer ${accessToken}` }
});
console.log('Page created:', response.data);
return response.data;
} catch (error) {
console.error('Error creating page:', error.response ? error.response.data : error.message);
return null;
}
}
createCoursePage(courseId, pageTitle)"