cancel
Showing results for 
Search instead for 
Did you mean: 
cdeville
Community Participant

Change course_code through Canvas API - not updating?

Jump to solution

I am using the Update a Course API to attempt to update a course_code (the course's shortname).

https://canvas.beta.instructure.com/doc/api/courses.html#method.courses.update

Using Postman, it builds this request (I am using PUT as specified):
https://uccs.instructure.com/api/v1/courses/:id?course_code='New course code set by API'

There are no errors returned, but the course code does not change either. It returns the course object - no changes.

Anyone been able to get anything under update a course to work? I tried some other fields but they don't update either.

Labels (1)
0 Kudos
1 Solution

Accepted Solutions
BrianLester
Community Participant

Something like this works for me:

https://yourschool.instructure.com/api/v1/courses/id?&course[course_code]=SampleNewCourseCode

Note: the sample course code is not in quotes.

You could try running your script in the Canvas Live API before postman...

View solution in original post

4 Replies
BrianLester
Community Participant

Something like this works for me:

https://yourschool.instructure.com/api/v1/courses/id?&course[course_code]=SampleNewCourseCode

Note: the sample course code is not in quotes.

You could try running your script in the Canvas Live API before postman...

View solution in original post

James
Community Champion

@cdeville 

Buried in Brian's ( @BrianLester ) answer is the key. There is no course_code parameter. There is a course[course_code] parameter.

If you're going to use JSON, which makes the structure clearer, it would be

{
  "course" : {
    "course_code" : "new course code"
  }
}

This is a common misunderstanding -- I've responded to similar issues several times in the last couple of weeks. When you look at the example requests at the bottom of the Update course endpoint, you will see the course[name] and course[start_at]. Those examples provide suggestions about how the call should be made.

cdeville
Community Participant

Thanks, I think this and Jame's answer are exactly what I need. But what do you mean by "Canvas Live API"? Is that where you login as a user with privileges and then try this in the browser?

James
Community Champion

@cdeville 

Canvas Live API resides at <yourCanvasInstance>/doc/live/api

You will need an API access token, but it shows the different APIs and endpoints, explains the information required and returned, and allows you to then test it out. You can then see the request that was sent so you can duplicate it on your end.

The information in the Live API is pulled from the source code, just like the REST API documentation, but sometimes it's easier to see exactly what Canvas is sending than it is to figure out what the documentation says.