SOLVED: I am not a coder, but I did figure this out, so I thought I would share in case someone stumbles across this old post.
The solution is that your Catalog listing data must be enclosed in a "course" container in your code, and there are some requirements around the image as well. Image Requirements:
- HTTPS URL (this is an assumption since my http url resulted in an error)
- URL ends with the image file extension (.jpg, .png)
- URL is publicly available.
- Image Size: Instructure support advised me that the image size for a course listing image is 1050 x 768px. I think you can be a little liberal with this, but how it fits in the listing image container could be affected (just as if you had uploaded it by hand).
This is a working API URL constructed and submitted with Postman (assumes authorization key is properly configured for Canvas API and you're using your own Catalog info) for a subcatalog with the account_ID 9999, a Canvas Course with ID 0001, course name, teaser, description, path, visibility, and listing_image as a URL
https://your-catalog-instance.instructure.com/api/v1/courses/?course[account_id]=9999&course[canvas_course_id]=0001&course[title]=API Course 1&course[description]=This is a description&course[teaser]=this is a teaser&course[path]=api-course-1&course[visibility]=listed&course[listing_image]=https://somesite.com/image.png
In my Ruby script (Mac), which pulls the data from a CSV file, it looks something like this when creating the listing - note the course container:
course:{
canvas_course_id: course_id,
title: listing_title,
path: listing_path,
teaser: listing_teaser,
description: listing_description,
visibility: listing_visibility,
account_id: subaccount_id,
listing_image: catalog_image
}
Final thoughts:
In my case my images are actually publicly accessible on the web, so the URL method works great for me. Consequently, I did not attempt a file upload from my computer.
In case you need to do this as an upload, this is what instructure shared with me about this workflow with a file upload, using cURL in their example:
curl -i 'https://instance.catalog.instructure.com/api/v1/courses' \
-X POST -H "Authorization: Bearer insert_token_here" \
-F 'course[title]=title_here' \
-F 'course[description]=description' \
-F 'course[path]=unique-path-here' \
-F 'course[teaser]=teaser' \
-F 'course[canvas_course_id]=course_id_here' \
-F 'course[listing_image]=@image_file.png'
If you are using an SVG image you also need to include the type with course[listing_image] added with something like:
-F 'course[listing_image]=@image_file.svg;type=image/svg+xml'
Cheers!
Melinda