The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
I have been tasked with unpublishing and publishing courses on a daily basis. Using the Advanced REST client, I am able to publish a course while it is in the unpublished state, however, I cannot unpublish a course once it is published.
I am using the PUT method for updating a course
When I run the request below, I am getting an OK response, but the course stays published. The request is as follows I am using to unpublish:
https://<domain>/api/v1/courses/<course>?event=claim&<accesstoken>
Isn't it beautiful when you can find your own answers...Correct syntax below:
https://<domain>/api/v1/courses/<course>?course[event]=claim&<accesstoken>
Can you provide an update on the status? Your last part sounds like it was an update where you answered your own question but then there's another "update" where you're having problems with Advanced Rest Client. Since none of those are timestamped, I'm not sure whether the problem is completely solved or still exists for ARC? If the problem is completely resolved, can you mark the question as answered?
On a related note, since you're using Advanced REST Client, you may want to go to the headers section and add your authorization token there. It saves having to add it to every query and it remembers it, which makes it so much nicer.
What you're doing works, but the top-level API Documentation page recommends the header while saying the query string is supported.
API authentication is done with OAuth2. If possible, using the HTTP Authorization header is recommended. Sending the access token in the query string or POST parameters is also supported.
Thanks for the tip. I removed the update, per your request as it could cause some confusion.
As for adding the auth token, it is asking for authorization data when I select OAuth 2.0, access token. What is the client id?
Or do I just not use the authorization tab at all and use the headers?
Do not use the Authorization tab at all as it doesn't support (at least I haven't figured it out) Authorization: Bearer.
Instead, go to the Headers tab and enter "authorization" as the header name and then "Bearer <accesstoken>" as the header value. I don't need a client ID or anything associated with OAuth2.
I also added the "content-type" of "application/json header". You might want to consider an "accepts" header with "application/json" as well. I haven't done this, but in other programming languages, Canvas has returned a while(1); in front of the JSON without that.
I copied the access token and did exactly what you said and I'm getting an invalid access token error.
Here are a few of things to check.
I don't use OAuth2, so I can't provide great assistance there. I went into Canvas, generated a token, and use that token as described above with no problems.
I definitely copied it correctly, as I have it in multiple places. However, I went and just generated a new token and it worked.
Thanks for the awesome help.
Glad you got it to work out as I was running out of suggestions.
@James , Thanks for your input. I have another question that I didn't think needed a new thread.
We have to deactivate certain students at the end of the school day and reactivate them the next morning. Is there a way to 'bulk' run a API request or would I need to run a bunch of individual requests; one for each student? If this is a case, do you know of a tool that could do this in a more automated way?
Thanks.
@brian_t_anders , this really is a different question, unrelated to publishing courses, so tacking it on here may not grab the attention or expertise it would if it was a separate question. It seems more related to the question you asked here Bulk activate and deactivate students than it does to this one.
That said, I'll go ahead and provide my thoughts.
First, what do you mean by "deactivate" the user? Users are active or deleted. Enrollments are active, deleted, completed, or inactive. There's not a way to deactivate a user at the account level that I know of and it's been a question or feature idea several times, including this one that is currently on Product Radar: https://community.canvaslms.com/ideas/7427-disabledeactive-user-at-account-level . That means that you're probably going to need to change their status in every course. Realize that doing so has ramifications for the teacher who may be grading off-hours when the students are not active in the course.
If you want bulk, then I would use the solution that @MattHanes gave in your other question and use a SIS import. I would make two enrollments.csv files with just those students in it. The name of the file seems to be irrelevant, so I would call them denyaccess.csv and allowaccess.csv or something like that to keep them straight. Since it's the same students, you don't even need to recreate the file, just keep sending the same pair over and over -- one every evening and the other every morning. Do this through SIS Import API. One API call is all it takes each time, rather than one for each student. I would schedule that request so I didn't have to make it manually. Your students would have to have SIS IDs for this to work.
If you want to stick with the API and not mess with SIS imports, then you would need to write a program that would loop through a list of students and send the API request for each one. I would schedule that as well.
Hi Brian
Is this true for the course that won't unpublish (taken from API documentation):
"A course cannot be unpublished if students have received graded submissions"
Thanks. I thought this may have been the case but was not. I was entering the wrong syntax.
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in