Getting 401 when trying to use the API to access Analytics

Jump to solution
ahibertjr
Community Novice

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)
0 Likes
1 Solution
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