User not authorized to perform that action

Jump to solution
sywang
Community Explorer

Hi all, 

I'm trying to accept a course invitation using a post request listed in the Cavnas API documentation. The command I'm using is:

"curl http://<canvas>/api/v1/courses/:course_id/enrollments/:id/accept \                                                

  -X POST \

  -H 'Authorization: Bearer <token>'"

However, I'm getting an error that says:

{"status":"unauthorized","errors":[{"message":"user not authorized to perform that action"}]}

Does anyone know how to fix this? For your reference, I'm using a Canvas instance hosted on AWS and have admin access to it. 

Thanks in advance!!

0 Likes
1 Solution
bbennett2
Community Champion

Check two things:

1. Your API key is valid. Will a GET request work?

2. You actually have a pending course invitation for your account. The API call runs as you, so if you don't have a pending invite, you can't accept it. 

If you're trying to automate accepting course invites for other users, you can masquerade your API call to act on someone else's behalf.

View solution in original post