New customer error: 'email': ['has already been taken']} & search.json sends empty {'customers': []}

bored
New Member
2 0 1

Hi, 

This happens only sometimes and not always. When a new user signups on my client's website and completes a registration process we create a new customer in shopify and generate a discount code for him through API.

Most of the times request goes through fine without any error. but sometimes it gives an error:

Rest API

API Version: '2020-10'

Request: 

POST /admin/api/2020-10/customers.json

response.reason = "Unprocessable Entity"

response.json:

 

 

{'errors': {'email': ['has already been taken']}}

 

 

if a customer exists already our backend tries to search for the customer (if it already exists it should be searchable right?):

Rest API

API Version: '2020-10'

Request: 

GET /admin/api/2020-10/customers/search.json?query=email:useremail@xyz.com;

response.reason = "OK"

response.json:

 

 

{'customers': []}

 

 

 but it gives empty json.

I have checked my database and user's email is not already in our system so it shouldn't exist in our Shopify account too.

Let me know if any more details are required.

 

Am I missing something. 

Can someone help please?

or point me to the right direction.

Any help is appreciated. Thanks

Greg_Kujawa
Shopify Partner
1016 83 238

Usually the Shopify support folks need a recent X-Request-ID that appears in one of the response headers. That way they can see the logs on their end. I do know that usually when I am dealing with event-type triggers my API requests need a slight pause. For example, if a new customer record is just created I pause my routine a few seconds to allow that transaction to commit on the back-end and refresh whatever behind-the-scenes hijinks are going on. Then I can usually query that new record just fine. May try that if you haven't already. If you already have, then that request ID will definitely help!

bored
New Member
2 0 1

Hi, Thanks for replying

I will try and find request-id in logs, though I am afraid I am not logging those.

But still if an email is a used for the first time in both our website and also in Shopify then why is the api responding with "Unprocessable Entity" (email has already been taken)

any Idea?

0 Likes
syf_
Shopify Staff
Shopify Staff
89 20 15

@bored as Greg indicated, if you could provide a request id (found in the response header) of a call that returns that error, it would enable us check the logs to see what might have gone wrong.

Thanks,
Seth.

syf_ | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
Eugene_404
Tourist
3 0 1

@syf_  we are getting the same issue:

  1. Customers Create returns: {"errors":{"email":["has already been taken"]}}
    • X-Request-ID: 790bb32e-6e21-4c33-a830-db8b9d731bd1
  2. Customers Search for the same email returns: {"customers":[]}
    • X-Request-ID: 5cb069d7-718c-4ac0-b636-c8c96bb80bed

We see this issue with the one partucular store. Plus, it happends for many of the emails for this store.

We tried it for two different API versions: 2021-07 and 2021-04.

We have a Postman collection with the above two requests if needed.

Can you please take a look into the issue?

syf_
Shopify Staff
Shopify Staff
89 20 15

Hi @Eugene_404,

I looked up the logs for those requests, and the email addresses used in the query were different. I haven't been able to reproduce this issue and I wanted to find out if you're still experiencing the issue consistently. If you are, could you provide me with recent x-request-id's?

Thanks,
Seth.

syf_ | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes