Attempting to update a FinalAdjustedGradeValue in Python.

I updated the Scope for my OAuth 2.0 application-
Scopecore:: datahub:dataexports:* grades:gradevalues:write
After getting my refresh token I have a simple post request which returns a 403 error - permission denied.
response = requests.post(
'https://my.d2lserver.com/d2l/api/le/1.39/1234/grades/final/values/111',
json={
'PointsNumerator': 97,
'PointsDenominator': 100
},
auth=HTTPBasicAuth('my_client_id', 'my_client_secret')
)
Any help would be appreciated!
Thanks,
Don
Best Answer
-
According to the docs this API point is PUT not POST. Then make sure you authenticate the app with at least instructor role.
Answers
-
Ahhh.. thank you. Still getting the same error. I'm using oAuth2 so I thought just the 'Scope' was needed.
Does the final adjusted grade need to exist already or can I set it if the grade does not exist?
-
you should use authorization bearer access token in the header not the auth basic
-
Getting much closer I think - I also found I needed to update the scope in my JSON file that keeps the last refresh token.
Now I have this code -
response = requests.put(
'https://my.d2lserver.com/d2l/api/le/1.39/9132/grades/final/values/310',
json={
'PointsNumerator': 97,
'PointsDenominator': 100
},
headers={'Authorization': 'Bearer longtokengoeshere'}
)I'm getting a new error - 404
- 404 Not FoundΒ β No such user in org unit, or no org unit found.
I'm sure the course offering is there and the user is in it⦠there are no grades or anything for the user in the course. I'm wondering if there is some nuance - maybe a final grade has to be issued ?
-
Your request calls to update the FinalAdjustedGradeValue. The 404 you get means you don't have it.
-
Try a GET request with the query string '?gradeType=adjusted' to check
-
ok, yeah. The grade is not there. So this is an update. I'd need to create the grade in order to be able to update it?