Shopify -使用Shopify api创建客户时面临的问题



我正在为shopify项目开发android应用程序。目前我在创建客户时面临问题。我试图解决它,如果有人知道这一点,请帮助我!

创建客户变更查询

const query= `mutation customerCreate($input: CustomerCreateInput!) {
customerCreate(input: $input) {
customer {
acceptsMarketing
email
firstName
lastName
password
phone
}
customerUserErrors {
field
message
code
}
variables: {
"input": {
"acceptsMarketing": true,
"email": "johnsmith@shopify.com",
"firstName": "John",
"lastName": "Smith",
"password": "5hopify",
"phone": "111111111111"
}
},
}
}`;
async function apiCall(query) {
return fetch('https://storename.myshopify.com/api/graphql.json', {
method: 'POST',
headers: {
'Content-Type': 'application/graphql',
'Access-Control-Origin': '*',
'X-Shopify-Storefront-Access-Token': token,
},
body: query,
})
.then(response => response.json())
.then(response => console.log('response: ', response))
.catch(error => console.log('error: ', error.message));

}

面对以下错误

{"errors": [{"locations": [Array], "message": "Parse error on "{" (LCURLY) at [16, 20]"}]}

使用以下查询。这对我很有效

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

}
}
}

错误告诉您在第16行第20列有一个解析*错误。解析错误通常指向拼写错误,我最好的猜测是:,你在第16行variables之后-这个符号应该在那里吗?

最新更新