A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I used cUrl to perform the ProductVariant update by referring to the official example, and it worked.
curl -X POST \
https://xxxx.myshopify.com/admin/api/2021-10/graphql.json \
-H 'Content-Type: application/graphql' \
-H 'X-Shopify-Access-Token: xxxxx' \
-d '
mutation updateVariants {
f1: productVariantUpdate(input: {
id: "gid://shopify/ProductVariant/xxxxx",
price: 120
}) {
userErrors { field, message }
},
f2: productVariantUpdate(input: {
id: "gid://shopify/ProductVariant/xxxxx",
price: 130
}) {
userErrors { field, message }
}
}
'
After that I send http request inside java using unirest tool, but it returns me 406.
// This value is the same as the parameter submitted by cUrl
String mutation = new String(Files.readAllBytes(Paths.get("hql.txt")));
String url = "https://mystore.myshopify.com/admin/api/2021-10/graphql.json";
HttpResponse<String> resp = Unirest.put(url)
.header("Content-Type", "application/graphql")
.header("X-Shopify-Access-Token", apiSecret)
.body(mutation)
.asString();
System.out.println(resp.getStatus() + " " + resp.getStatusText());
System.out.println(resp.getBody());
This is hql.txt
mutation updateVariants {
f1: productVariantUpdate(input: {
id: "gid://shopify/ProductVariant/xxxxx",
price: 120
}) {
userErrors { field, message }
},
f2: productVariantUpdate(input: {
id: "gid://shopify/ProductVariant/xxxx",
price: 130
}) {
userErrors { field, message }
}
}
Hi @xsjiang
Can you please log all the request header fields you are including in the request *aside from password/authentication fields* and post them here?
Thanks!
To learn more visit the Shopify Help Center or the Community Blog.