cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Member

REST API how to associate to blueprint course

Jump to solution

We are trying to automate the process of associating courses to blueprint courses.  The workflow we want to implement is to have a form in our website where the director of elearning submits a csv file which creates the associations.  We already have something similar for creating assignments.  To achieve this we are looking at "Update associated courses"  (https://canvas.instructure.com/doc/api/blueprint_courses.html#method.master_courses/master_templates...) but I assume we must be missing something simple because whatever we try it returns "The specified resource does not exist".  The documentation provides the following path :

PUT /api/v1/courses/:course_id/blueprint_templates/:template_id/update_associations


We're assuming the issue relates to the course or blueprint_template id.  It seems unlikely to me that the course id and the course_ids_to_add would be the same.  So should the course id be the blueprint course id?  If that is the case then what is the template_id and where would we find that?

https://somewhere.beta.instructure.com/api/v1/courses/5475/blueprint_templates/6641/update_associati...

If anyone has any experience or insight into this it would be greatly appreciated.

N.B The above url is used in Postman and consequently it will make the necessary substitutions to ensure the url format is valid (e.g the ending will be &course_ids_to_add%5B%5D=5475 but have left as is for clarity).

Labels (1)
1 Solution

Accepted Solutions
Highlighted
Community Advocate
Community Advocate

I just tested this out since I'm going to probably have to start using this at some point. According to the API documentation, the "template id" for now is just the word "default". Here's what the documentation says:

Using 'default' as the template_id should suffice for the current implmentation (as there should be only one template per course). However, using specific template ids may become necessary in the future

So in the Put command, you're deciding what courses to associate with a blueprint course. All the association stuff happens in the blueprint course so the "course_id" is the course id for the blueprint. The "courses ids to add" array lists all the courses you want associated with the blueprint.

For example, if the blueprint course is 1111 and you want to associate course 1112 then the url in Postman will look like this:
242244_pastedImage_2.png

View solution in original post

18 Replies
Highlighted
Community Advocate
Community Advocate

I just tested this out since I'm going to probably have to start using this at some point. According to the API documentation, the "template id" for now is just the word "default". Here's what the documentation says:

Using 'default' as the template_id should suffice for the current implmentation (as there should be only one template per course). However, using specific template ids may become necessary in the future

So in the Put command, you're deciding what courses to associate with a blueprint course. All the association stuff happens in the blueprint course so the "course_id" is the course id for the blueprint. The "courses ids to add" array lists all the courses you want associated with the blueprint.

For example, if the blueprint course is 1111 and you want to associate course 1112 then the url in Postman will look like this:
242244_pastedImage_2.png

View solution in original post

Highlighted

Thanks Matt that was exactly the snippet I was missing.  I see now it is explained further up the page.  My bad for not seeing that.

Highlighted

Hanes.Matthew.B@muscogee.k12.ga.us, Is this still endpoint working as intended as you see it? Any time I'm attempting to run an API call with this endpoint it's giving me the HTML contents of the Canvas error page in the response rather than a JSON object. Here's my Postman setup:

Postman Set up

The HTML in the response amounts to the standard Canvas Error page:

Error Page

I know it says 'Beta' on the API docs, but if you're getting the same thing then I'm wondering if this is a support issue that needs to be filed?

Thanks!

Highlighted

It's still working for me. I can't see your entire URL in your screenshot but I'm guessing that's where the error is.

Highlighted
Learner II

Here's another look at the same setup in Postman with the full URL:

Postman Round 2

Here's the full text of the request URL

https://<canvas_instance_domain>/api/v1/courses/1008844/blueprint_template/default/update_associations?course_ids_to_add[]=1008845‍

Thanks!

Highlighted

Yeah, the URL should be blueprint_templates and not blueprint_template.  They used the plural. Just add an 's' and it should work.

Highlighted
Learner II

That's the issue. Thanks! I'm embarrassed to admit I didn't see this earlier as I'm usually pretty detail oriented. I just needed a second pair of eyes. :smileycool:

Highlighted

No worries! Happens to us all :smileygrin:

Highlighted

Hanes.Matthew.B@muscogee.k12.ga.us, I'm glad I came across your post. It really clears things up about the course_id and blueprint_id situation.

I'm having a different learning issue here, though, perhaps you can help me identify the error of my way.

First, I have an existing course, formerly associated with BP "A". I have broken the association and can verify through both BP "A"s association list and the course settings which no longer show the BP tie. I have also reset the course.

I believe I have a correctly constructed URI and have tried both a PowerShell script and Postman to invoke the command. I'm getting the same response either way: The remote server returned an error: (422) Unprocessable Entity.

I'm working in my beta instance and the command URI looks like this:

/api/v1/courses/990/blueprint_templates/default/update_associations?course_ids_to_add[]=445

 

  • 990 is the course id of BP "B" -- and the course resides in the top-most account on our system, nicely rooted above the account where the course lives.
  • 445 is the course id of my existing course I wish to associate with BP "B"
  • I have the plural "templates"

I just don't know what else to check. :smileysilly: Thanks for any suggestions!

0 Kudos