Feature request: can't lookup Civi ID based on Drupal username via API
When visiting https://exmple.com/civicrm/api#explorer
, select "User" from the Entity
dropdown menu. Then change Fields to return
to "ContactID", and under that, change "ContactID" to "username", then enter your user name. Copy the example Drush command into a terminal as root under the document root for your server. This error is returned:
Mandatory key(s) missing from params array: contact_id [error]
If you try again, but this time choose "CMS User ID" as the parameter, and enter your CMS User ID, then run the command, then the query works:
...
[contact_id] => 123929
...
The desired behavior is that querying by username would work, and for the parameter list to perhaps not show an asterisk next to the "Contact ID" option, as if it is required for all queries using that Entity. (It's currently possible to use the "CMS Contact ID" instead.)
Being able to search by username would help remote applications to log people in via a single-sign-on system that returns the user name to that remote application, then to access their Civi accounts via the API. There are ways to work around this issue, but I thought I should mention this scenario in case the behavior of this part of the API is inteded to cover this use case.
Thanks! : )