Development discussions around Shopify APIs
Hey, I want to create a customer with password using the graphql api. I followed the documentation to create a customer with password to avoid the activation process by email, this is the query I'm sending:
mutation { customerCreate( input: { firstName: "dave", lastName: "smith", email: "someone@gmail.com", password: "12345" acceptsMarketing: true, } ) { customer { id firstName lastName email } userErrors { field message } customer { id } } }
But I'm getting this error as if the specification changed:
{ "errors": [ { "message": "InputObject 'CustomerInput' doesn't accept argument 'password'", "locations": [ { "line": 7, "column": 11 } ], "path": [ "mutation", "customerCreate", "input", "password" ], "extensions": { "code": "argumentNotAccepted", "name": "CustomerInput", "typeName": "InputObject", "argumentName": "password" } } ] }
How do I do to achieve this? Thanks!
Solved! Go to the solution
This is an accepted solution.
Hey there,
You might be seeing this error because your request is targeting the GraphQL Admin API and not the Storefront API. I would take a look at this guide which outlines the steps you need to follow.
Namely, you need to be using the proper GraphQL endpoint - `POST https://my-store-name.myshopify.com/api/graphql` and you need to provide the `X-Shopify-Storefront-Access-Token` header with your Storefront Access Token which is different from your Admin Access Token.
This is an accepted solution.
Hey there,
You might be seeing this error because your request is targeting the GraphQL Admin API and not the Storefront API. I would take a look at this guide which outlines the steps you need to follow.
Namely, you need to be using the proper GraphQL endpoint - `POST https://my-store-name.myshopify.com/api/graphql` and you need to provide the `X-Shopify-Storefront-Access-Token` header with your Storefront Access Token which is different from your Admin Access Token.
Thanks!
I realize this thread is a bit old and marked as "Solved", but it's worth mentioning that not supporting a password field from the Admin API is a real issue. It doesn't make sense that the only way you can create an account with a password is with the Storefront API. There are other fields (e.g. locale) in the Admin API that we require anyway, so we'd have to use a combination of both. It looks like for now we might have to use a combo of the REST and GraphQL Admin API.
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023