cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
lyleh
Community Member

Blueprint attribute of GET Course api always returns false

Jump to solution

I am trying to mark courses as blueprint courses via the api. I am using Powershell and to start I am using curl do a GET as follows:

curl -H @{"Authorization" = "Bearer <token>"} -Method GET "https://canvas.instructure.com/api/v1/courses/<id>"

This call always returns blueprint=false.

I have tried doing an update via curl

curl -H @{"Authorization" = "Bearer <token>"} -Method PUT -Body "course[blueprint]=true" "https://canvas.instructure.com/api/v1/courses/<id>"

I can change the Name and other attributes. I also can change the Blueprint setting in the Canvas UI but the GET still returns blueprint=false.

Any guidance welcome.

 

 

 

Labels (3)
0 Kudos
1 Solution

Accepted Solutions
lyleh
Community Member

Xavier 

Thanks for the answer. Unfortunately I am using Powershell so -F didn't work but when I researched what the difference was between -Body and -F I found what worked for me. I had to add a -ContentType.

$postParams = @{"course[blueprint]"="true"}
$res = @{"Authorization" = "Bearer <token>"} -Method PUT -Body $postParams -ContentType application/x-www-form-urlencoded "https://<canvasurl>/api/v1/courses/101"
$res.Content

That worked for me and I saw the updates immediately reflected in Canvas UI.

Lyle

View solution in original post

3 Replies
xcotto1
Community Member

Hi @lyleh 

 

instead of using -Body you can use -F or --form. Here is an example and it worked for me.

 

curl -H 'Authorization: Bearer <token>' -X PUT -F 'course[blueprint]=true' https://canvas.instructure.com/api/v1/courses/58628

 

 

I hope this works for you.

-Xavier👾

lyleh
Community Member

Xavier 

Thanks for the answer. Unfortunately I am using Powershell so -F didn't work but when I researched what the difference was between -Body and -F I found what worked for me. I had to add a -ContentType.

$postParams = @{"course[blueprint]"="true"}
$res = @{"Authorization" = "Bearer <token>"} -Method PUT -Body $postParams -ContentType application/x-www-form-urlencoded "https://<canvasurl>/api/v1/courses/101"
$res.Content

That worked for me and I saw the updates immediately reflected in Canvas UI.

Lyle

View solution in original post

xcotto1
Community Member

Awesome!, I'm glad in some way you were able to figure this out 😎

 

Happy weekend!,

-Xavier👾