Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ahibertjr
New Member

Getting 401 when trying to use the API to access Analytics

Jump to solution

I am a complete beginner in using APIs, but I am trying to learn. I was trying to access the student activity analytics for a course I'm teaching, but I keep getting a 401 code as a return.

I have tried adding the token as part of the URL request:

https://lalala.instructure.com/api/v1/courses/XXXX/analytics/activity?access_token=1XX0~9L1Im4w8DXXX...

 

And adding the header as a separate variable in the GET request

header <- "{Authorization : Bearer 1XXX0~9L1Im4w8XXXX}"

GET(url = url, header = head)

I am at a loss. Is it that analytics can only be accessed by certain users (meaning I'd have to ask for additional permissions from my IT department), or am I doing something wrong here?

Labels (1)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
pklove
Community Champion

What role do you have in the course?

If you are a teacher you should be able to access that endpoint.

Does it work if you log in using your browser and then go to (no token required):

   https://lalala.instructure.com/api/v1/courses/XXXX/analytics/activity

View solution in original post

3 Replies
pklove
Community Champion

What role do you have in the course?

If you are a teacher you should be able to access that endpoint.

Does it work if you log in using your browser and then go to (no token required):

   https://lalala.instructure.com/api/v1/courses/XXXX/analytics/activity

No, I'm still getting access denied. I've checked my role in that class and am enrolled as "virtual teacher". Does that come with less permissions than regular teacher?

I checked on a colleague's account (he's enrolled as physical teacher) and he does have access, so it's a problem with the permissions given to "virtual teachers". Oh, well. Time to talk to IT.

Thank you very much!