Search code examples
apirestdesire2learn

Use Valence to Get User Data


According to the documentation I can get user data by calling:

GET /d2l/api/lp/1.0/users/

And I can use the d2lId, username or bookmark param. I have tried this simply by appending the username string to the uri but it didn't work. Does the uri require a parameter name in order to understand what param I'm submitting to the query? i.e. ?username="someUsername"

Note that I have been able to return user specific data by simply appending the d2lId to the uri so API access is a non-issue. Also LE version is not an issue - I'm using > 9.4.1.


Solution

  • You're conflating two different calls, and this is the source of the confusion. The call to the users/ route mentioned in your question is one to fetch back data for all users (in data pages):

    • orgDefinedId -- provide an org-defined identifier, and seek for matches against that
    • userName -- provide a user name, and seek for matches against that
    • bookmark -- provide the bookmark needed to fetch the next data page

    So in your example, the API call could look like this:

    GET /d2l/api/lp/1.0/users/?userName=Bob%20Roberts
    

    Notice that there's also a route to fetch the user data for a particular user identified by LMS UserId value:

    GET /d2l/api/lp/1.0/users/123456
    

    But these are actually two different REST routes. You can't use the LMS UserId as a filter for the users/ route...