1

I have a requirement that I need to migrate users from a remote RMS to existing magento 2 website using Rest API. Migration will either create new user if it doesn't exists or will update the existing user. For both cases I need to find if a particular user having an email address already exists in the magento system or not. If the user exists then I need th customerId (PK) so that I can send the customerID with updated customer details in the api.

So is there any way to find user details using customer email address in magento 2 using REST API? Please let me know.

Thanks Jawed

2
0

By now, I'm sure you've moved on. But, to anyone else that might get here wondering the same thing.

There's two ways to solve this:

Method 1: use GET /V1/customers/isEmailAvailable

This method is nice since it just returns a simple true|false on whether the email is inuse/available for that particular website ID.

Method 2 (my preference): you merely need to "search" for the customer based on their email.

The following REST call will return you the customer record based on their email or an empty set (as of v2.3):

GET /V1/customers/search?searchCriteria[filterGroups][0][filters][0][field]=email&searchCriteria[filterGroups][0][filters][0][value]=<email_address>&searchCriteria[filterGroups][0][filters][0][condition_type]=eq

replace <email_address> with the URL encoded email you are checking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.