Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Reference:
https://shopify.dev/docs/admin-api/rest/reference/metafield
I am trying to add a metafield for a product by making a REST call using format:
POST https://[KEY]:[PASS]@[SHOP_NAME].myshopify.com/admin/api/2020-04/products/[PRODUCT_ID}/metafields.json
with body:
{
"metafield":
{
"namespace": "resource",
"value_type": "string",
"value": "my custom value",
"key": "my_custom_key",
"description": "The description."
}
}
But I receiving a response with status 400 like:
{
"size":0,
"timeout":0
}
What am I doing wrong?
Hey @DSL
400 indicates a bad request. How are you sending the request? Is the Content-Type application/json?
Scott | Developer Advocate @ Shopify
Yes, content-type is set to application/json
Are you able to capture a request ID from the response headers?
Scott | Developer Advocate @ Shopify
Has a solution ever been provided? I too cannot create a metafield for a product using the admin api. I did the following:
URL: https://{API Key}:{Password}@{MyStore}.myshopify.com/admin/products/{product-id}/metafields.json
Action: Post
Body:
I even tried using basic authentication with the username set to my API key and the password with my API password and removed those values from the URL but I still get the same response in which no metafield gets created.
@robertjla - I've replied on your other thread.
https://community.shopify.com/c/Shopify-APIs-SDKs/Can-t-Perform-POST-using-REST-API-and-Basic-Authen...