cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
czehner1
Community Member

API Get User by Login_ID

Jump to solution

Hello!

Having a bit of trouble with the REST API. We are attempting to get a singular user from an API, but need to do so from a specific field, that field being the login_id.

We have found success is using this call:

 

 

{domain}/api/v1/users/sis_user_id:{sis_id}

 

 

but when we try to do the same with login_id instead of sis_user_id, we get a message saying "The specified resource does not exist." 

Is there another way we can phrase this call to make it work? I haven't found anything on the community forums nor documentation as of yet.

Thanks!

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
James
Community Champion

@czehner1 

The sis_ notation is specific to SIS IDs. There is a list of ones that you can use in the API documentation.

If the token making the API call has admin rights, then you can use the List users in account endpoint of the Users API and use the search_term parameter. The description mentions " Queries by administrative users will search on SIS ID, login ID, name, or email address."

Note that searching is not as fast as a direct reference by Canvas ID or SIS ID.

The search looks at multiple fields, matches partial values, and may return multiple responses. You will need to filter the responses to find the one that you're looking for. For example, if I search for "jsmith" at our institution, I come up with 11 responses, only one of which has a login id of jsmith. The others might be cjsmith or jsmith1.

Also note that you need at least 3 characters to do a search and using a short search can return a lot of responses. The search appears to be capped at 15 responses per search, so you may need to use pagination to get the correct response.

Depending on your application, you may want to store IDs locally rather than searching by login id on a regular basis. I have a local database that contains the login ID, Canvas ID, and SIS ID so that I can don't have to use Canvas for that information.

View solution in original post

1 Reply
James
Community Champion

@czehner1 

The sis_ notation is specific to SIS IDs. There is a list of ones that you can use in the API documentation.

If the token making the API call has admin rights, then you can use the List users in account endpoint of the Users API and use the search_term parameter. The description mentions " Queries by administrative users will search on SIS ID, login ID, name, or email address."

Note that searching is not as fast as a direct reference by Canvas ID or SIS ID.

The search looks at multiple fields, matches partial values, and may return multiple responses. You will need to filter the responses to find the one that you're looking for. For example, if I search for "jsmith" at our institution, I come up with 11 responses, only one of which has a login id of jsmith. The others might be cjsmith or jsmith1.

Also note that you need at least 3 characters to do a search and using a short search can return a lot of responses. The search appears to be capped at 15 responses per search, so you may need to use pagination to get the correct response.

Depending on your application, you may want to store IDs locally rather than searching by login id on a regular basis. I have a local database that contains the login ID, Canvas ID, and SIS ID so that I can don't have to use Canvas for that information.

View solution in original post