Development discussions around Shopify APIs
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!
CS | API 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
User | RANK |
---|---|
8 | |
7 | |
3 | |
3 | |
3 |
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By