I was curious as to whether anyone has successfully implemented in Java the route in D2L using Valance as follows:
PUT /d2l/api/le/(D2LVERSION: version)/(D2LID: orgUnitId)/grades/(D2LID: gradeObjectId)/values/(D2LID: userId)
I have been struggling with receiving a 404 from this call when I have checked thoroughly that the required IDs match my records in D2L. When I log into D2L with the Instructor level account that I am using in Java I see that the Course, Test, and Participants are there. The IDs for these are used in the Java code to call the above route, but I receive a 404 and a grade is not updated.
Here is a snip of the code:
HttpURLConnection connection = null ;
try {
uri = userContext.createAuthenticatedUri ("/d2l/api/le/1.0/"+courseId+"/grades/"+gradeId+"/values/"+ userId, "PUT");
connection= (HttpURLConnection)uri.toURL().openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("PUT");
connection.setRequestProperty("Content-Type", "application/json");
OutputStream os = connection.getOutputStream();
String updatedScore = "{\"GradeObjectType\":1,\"PointsNumerator\":\"5\"}";
os.write(updatedScore.getBytes());
os.flush();
}catch(Exception e){
e.printStackTrace();
}
The courseID, gradeID, and userID are being passed in and have been verified in the D2L Web UI. As you can see, I have a JSON string being created for a GradeObjectType of 1 and a PointsNumerator of 5. Are there special permissions that this Instructor account must have beyond the default Instructor account permissions to permit such a call?
Any thoughts would be appreciated. Thanks
update:
An example of a successful request and response follows, perhaps you can identify differences:
REQUEST:
PUT https://valence.desire2learn.com/d2l/api/le/1.0/7574/grades/4852/values/3902?x_b=xDaPHeptaw9syoI1EGdeJ1&x_a=L2Hd9WvDTcyiyu5n2AEgpg&x_d=6U5NTYnTswz4gnu-vZHT3bajswsp3jvxYtwzoeOWKUs&x_c=a6f5hEMrvAxC6PS5UlSUOusVpj-XKnOBwxqhYg5pNtg&x_t=1343070852 HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/json
{
"GradeObjectType": 1,
"PointsNumerator": 9
}
RESPONSE:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 0
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Date: Mon, 23 Jul 2012 19:14:48 GMT