Development discussions around Shopify APIs
To continue receiving payouts, you need to secure your account by turning on two-step authentication. If two-step authentication is not turned on your payouts will be paused. Learn more
We are having issues using the metafields on a product on the /admin/api/2020-07/products.json rest api endpoint.
If "metafields" is either not included, or is set to an empty array, the product is creating without issue.
However when trying to create a product with metafields we are receiving the following error :
{"errors":{"metafields":"expected Hash to be a Array"}}
This is happening on both creates and updates.
Sample request payload :
{
"product": {
"product_type": "Physical Product",
"title": "Metafield Example Product",
"body_html": "",
"variants": [],
"images": [],
"tags": "",
"metafields": [
{
"key": "option_one",
"field": "metaOptionOne",
"value": "Wishlist potential: High",
"namespace": "custom_fields",
"value_type": "string"
},
],
"published": true,
},
}
Hello @BillyH,
I've tried to replicate the issue without success. Looking at the application logs, I've noticed four 400 Bad Request from Sep 22 through Sep 24 on this endpoint.
These bad requests and the error message you've received can be explained if the payload sent metafields as a JSON object rather than an array.
Payload:
{
"product": {
"product_type": "Physical Product",
"title": "Metafield Example Product",
"body_html": "",
"variants": [],
"images": [],
"tags": "",
"metafields": {
"key": "option_one",
"field": "metaOptionOne",
"value": "Wishlist potential: High",
"namespace": "custom_fields",
"value_type": "string"
},
"published": true
}
}
Response:
{
"errors": {
"metafields": "expected Hash to be a Array"
}
}
Welcome the forums @edaroit strong start hitting it out the park with a first post.
User | RANK |
---|---|
6 | |
5 | |
5 | |
5 | |
4 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022