Getting Errors with REST API Delete for Sections

Jump to solution
Community Contributor

I'm having a couple problems using the REST API (via Canvaspest, but I'm also hitting it using CURL) to handle enrollments: 

This works fine:

curl -X POST "" \
-H "Authorization: Bearer supersecretblahblahblah" \
-F   "enrollment[user_id]=18" \
-F   "enrollment[type]=StudentEnrollment" \
-F   "enrollment[enrollment_state]=active" \
| jq --raw-output  ‍‍‍‍‍‍‍‍‍‍‍‍

So for testing user enrollments, that works fine: 

  "id": 444839,
  "user_id": 18,
  "course_id": 27954,
  "type": "StudentEnrollment",
  "created_at": "2017-09-18T22:22:29Z",
  "updated_at": "2017-09-18T22:22:29Z",

But then this doesn't work:

curl "" \
-H "Authorization: Bearer supersecretblahblahblah" \
-F 'task=delete' \
| jq --raw-output  ‍‍‍‍‍‍‍‍‍‍

Is the documentation wrong?  Both Enrollments - Canvas LMS REST API Documentation and the Canvas Live API indicate that the delete should work, but I get this error (and I've confirmed the tokens are identical, so it's not invald):

  "errors": [
      "message": "Invalid access token."

Am I just making a huge obvious mistake? 

Labels (1)
1 Solution
Community Champion

The delete should work.

There is a slight difference in your URLs.  The delete has "temple" instead of "templeu".

Both resolve and go to different IPs so I'm guessing the delete should have "templeu".

So you get the error because you are using the templeu token to make a call to temple.

View solution in original post