Valence - Auditor Creation

60 views
Skip to first unread message

Joseph Price

unread,
Feb 3, 2014, 11:49:15 AM2/3/14
to valenc...@googlegroups.com
Hi,
I'm creating a custom application to create auditor\auditee relationships in the D2L learning environment. The basic flow of this app is to set a particular user as an auditor for another user. Simple enough :)

To start with, we are using our org defined ID's as identifiers for the users in our process so we have to use this route to first get their D2LID
/d2l/api/lp/1.3/users/?orgDefinedId=[our org defined ID]

That part is working like a charm so once I have those D2LID values for each user in a variable I am attempting to call this route to create the auditor relationship
/d2l/api/le/1.3/auditing/auditors/[D2LID for the auditor]/auditees/

Along with these JSON parameters
{ "AuditorID" :[D2LID for the auditee] }
This route is explained here

Unfortunately, I am getting an HTTP/1.1 404 Not Found response. This leads me to believe that either my environment may not have auditing available or my request string is somehow incorrect. I have a fiddler trace of the request that I can attach but I need to look at it before I attach to make sure I'm not uncovering any sensitive information.

Also, if you need it, here is the code block that creates the request and executes it but I get the same response even when I test the routes from D2L's Valence test site
// Create Auditor Relationship
var request_create = new RestRequest("/d2l/api/le/1.3/auditing/auditors/" + auditor_d2lid + "/auditees/", Method.POST);
request_create
.RequestFormat = DataFormat.Json;
request_create
.AddBody(new { AuditeeId=auditee_d2lid });
auth
.Authenticate(client, request_create);
var response_create = client.Execute(request_create);
Console.WriteLine("Auditor Relationship Creation Status: " + response_create.StatusCode);
Console.ReadKey();

Thanks for any help you can offer... it is much appreciated :)
- Joe Price

Desire2Learn Staff: Sarah-Beth

unread,
Feb 3, 2014, 1:41:11 PM2/3/14
to valenc...@googlegroups.com

It looks like you're sending the AuditeeId in a format the API doesn't expect. Basically, the route is expecting a JSON number, rather than a more complex JSON object. There's a related question on StackOverflow where another Valence Community Member did the same thing with a different call: http://stackoverflow.com/questions/21444939/what-is-the-expected-json-block-for-a-desire2learn-post-org-parent. Take a look at the response on StackOverflow for details, and let me know if that resolves the issue for you.

Joseph Price

unread,
Feb 3, 2014, 1:58:40 PM2/3/14
to valenc...@googlegroups.com
Hi Sarah-Beth,
That did it! Thanks for the help. I changed my code to this:

// Create Auditor Relationship
var request_create = new RestRequest("/d2l/api/le/1.3/auditing/auditors/" + auditor_d2lid + "/auditees/", Method.POST);
request_create
.RequestFormat = DataFormat.Json;
request_create.AddBody(auditee_d2lid);

auth
.Authenticate(client, request_create);
var response_create = client.Execute(request_create);
Console.WriteLine("Auditor Relationship Creation Status: " + response_create.StatusCode);
Console.ReadKey();

 Which defines the JSON as simply a number representing the auditee's D2L ID and it worked!

Thanks again
- Joe Price

Desire2Learn Staff: Sarah-Beth

unread,
Feb 3, 2014, 2:00:30 PM2/3/14
to valenc...@googlegroups.com
Perfect! Glad it worked out. Thanks for updating us to confirm the change!
Reply all
Reply to author
Forward
0 new messages