instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.71k stars 2.52k forks source link

Update Course image in Settings using API #2320

Open vishalgvk opened 9 months ago

vishalgvk commented 9 months ago

Summary: Unable to update image of Course in CourseSettings using API

Steps to reproduce:

  1. PUT request to /api/v1/courses/:courseId/settings with request body being { "image_id": "1" , "image_url": _imageUrl_ , "image": _imageUrl_ }
  2. Postman gives response 200 with old CourseSettings object as response (image isn't being updated)

Please let me know if it's possible to update image or bannerImage of Course using API

vishalgvk commented 9 months ago

I found the solution after multiple trials.

Solution: Send a PUT request to Course (but not CourseSettings) passing only image_id (image_url and image aren't required). In the response, even though the updated data doesn't appear, that's fine. We have to verify the updated image_id by making GET request to CourseSettings (but not Course).

So, this can be considered as a bug in canvas-lms api.

clrockwell commented 1 day ago

Thanks for this - this helped me set the images. I'm not sure this is a bug though as I've since found it is documented: https://github.com/instructure/canvas-lms/blob/3571f46bdf7ad07baa781335053e5f47fbd7a5c5/app/controllers/courses_controller.rb#L2984