I'm working on a PHP script that will retrieve the last_login value for an admin user. Here is the endpoint that I am using:
/api/v1/accounts/1/users?search_term=$login_id&include[]=last_login
The problem is that when we execute this, we sometimes get TWO user objects. For example:
/api/v1/accounts/1/users?search_term=someone@somewhere.com&include[]=last_login
returns two admin accounts, one with the someone@somewhere.com login id, and one with a totally different login id, and the value of last_login is entirely different for each of them. Why could this be happening?
What is the email address and name for the one that does not have login_id someone@somewhere.com ?
Entirely different. Let's say that the first person is named Joe Smith; then the second person is Kathy O'NoName, with the email address kathy@somewhere.com.
Edit: I just realized that person 1 and person 2 have the same email domain.
I just managed to reproduce this - and the users have different email domains.
Its the same if I search in the GUI as an admin in People.
I get back three, two would be expected, one has no current details that match the search. But the odd one out is a test account that I use, and the other two are also accounts I use. Spooky!
I wonder if the odd one out used to have something matching the others and Canvas is finding these details. Eg., a deleted login. Deleted things are often really still there.
BTW, this is a nice way to get last logins. How did you know about the include[]=last_login? Its not in the docs at Users - Canvas LMS REST API Documentation
My co-worker figured it out. I don't know how, but we've used it for a couple of things.
I wonder what's going on with this behavior. I haven't found anything online to suggest a way around it.
Oh well, for now, just have to allow for multiple results and grab the one that actually matches. Should probably be doing this anyway as you don't know what will come back.
Here's a strange nuance... I tried searching by id, but when include[] is specified, then the search parameter will only accept string input. So I tried searching by id, but without the include[]=last_login parameter. However, it still returned two results for the user in question, which is really starting to irk me.
Were you able to find an answer to your question? I am going to go ahead and mark this question as answered because there hasn't been any more activity in a while so I assume that you have the information that you need. If you still have a question about this or if you have information that you would like to share with the community, by all means, please do come back and leave a comment. Also, if this question has been answered by one of the previous replies, please feel free to mark that answer as correct.
Robbie