How to create a new course with Canvas API

AntoManzur
Community Member

Hello, i'm trying to create a new course with the API but i'm getting this result:

{
"result": null
}

This is what i'm doing:

const courseData = {
        course: {
            name: titleSection?.title ?? 'Unnamed Course',
            course_code: '',
            default_view: 'syllabus',
            course_format: '',
            license: 'private',
            syllabus_body: ''
        },
        enroll_me: true
    };

    try {
        const courseResult = await fetch(`${canvasUrl}/api/v1/accounts/self/courses`, {
            method: 'POST',
            headers: {
                'Authorization': 'Bearer ' + accessToken,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(courseData)
        });
        return await courseResult.json();
 
Does anyone know why i'm getting a null?
Labels (2)
0 Likes