Page creation Program

HortonShine2
Community Member

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: {
              url: 'https://api.eng.hmhco.com/lti-deep-linking/api/1.3.0/lti', // Your LTI tool launch URL
              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)"
0 Likes