Why cannot I retrieve users.id via users.email address?
Hi, I am really struggling to figure out why I cannot retrieve a user id from an email address. I have tried the v1 API and keep getting a 100 error. I have tried the v2 API and get the error below....
{ "status" : "error", "message" : "invalid query syntax for SELECT id FROM users WHERE users.email = 'user@email.com'", "data" : { "type" : "error_data", "code" : 604, "developer_message" : "", "more_info" : "" }, "metadata" : { } }
I've been using the v2 API regularly since starting with Lithium, I have auth code and this works. I refreshed my auth code before attempting this and tried other queries which worked. The querY I fired is below (encoded)....
https://api.lithium.com/community/2.0/{code removed}/search?q=SELECT%20id%20FROM%20users%20WHERE%20users.email%3D%27user%40email.com%27&api.pretty_print=true
....(decoded)....
https://api.lithium.com/community/2.0/{code removed}/search?q=SELECT id FROM users WHERE users.email='user@email.com'&api.pretty_print=true
Also, in the error codes section, code 604 is given as an example but isn't explained?!
This is just because 'email' is not a valid constraint for the object 'users' , and you are using "WHERE users.email='user@email.com'" in the API.
Here is the list of all constraints for users data you can use in V2 API.
Thanks Parshant.
This is frustrating since it is not made very clear. The LiQL language documentation should really make things like this clear since it is based so heavily on SQL which does not have these constraints.
Anyway, I managed to resolve this by using the v1 API.......which is also not very clearly documented. So, to make it clear for others, if you want to use OAuth credentials and the v1 API for this, the URL you need is this....
https://api.lithium.com/community/v1/{tenant_id}/users/email/user@email.com?restapi.response_format=json
The headers need to be configured as described in the documentation