Best Answer

Get userid from username

  • 21 December 2023
  • 1 reply
  • 68 views

Hi there

I’m trying to add more infromation to a report for the whole enrolled users to a specific course

the first step was something like this

GET

{url_root}learn/v1/courses/report?page={k}&idCourse={id_course}&page_size= xx

Awesome! I have my usernames list

the response has only these parameters

{"username":"qqq","first_name":"pppp","last_name":"pppp","status":"0","enrollment_date":"2021-11-04 14:57:40","time_in_course":null,"last_access":null,"completion_date":null,"score":"0.00"}

Now the need is add all the custom fileds defined for each username

In the api catalogue I didn’t  find methos with the username in input. All work with userid (this info is missing in the first response) as inquery parameters.

How can I collect the userid strating from username?

Thanks for your help

icon

Best answer by Bfarkas 21 December 2023, 17:29

View original

1 reply

Userlevel 7
Badge +3

If you are using the api only for this, I think you’d basically have to use the “get list of users” endpoint and use the search/filters to basically make it a list of 1 user. You’d then have to go get user information for complete info, 3 calls for 1 user. That being said, especially depending on volume you are using for this, I often will use the reports combined with the API for something like this, keep an updated version of the all users report for example with all the additional fields so that you can use it as a lookup table instead of list api and then specific user api. Just a thought. 

Reply