HI to everybody
I’m in toruble with adding a new product with metafield.
The scenario is this one:
I have created some product metafields from dashboard
When I create a new product with REST API call I pass this data:
$product = array(
“product”=>array(
“title”=> “Product Title”,
“body_html”=> “Product description blah blah blah”,
“product_type”=> “Watch”,
“published”=> true ,
array(“metafields”=>array(“namespace”=>“custom”,“key”=>“movimento”,“value”=>“Automatico”,“type” => “single_line_text_field”))
)
);
The product is created without metafield. The metafield part passed is the same copied by REST API online example
On the Dashboard I have this data for the metafield use:
namespace → “custom”
key → “movimento”
values → “Automatico”,“Manuale”,“Quarzo”
Where I’m wrong ?
I jave checked many times the sybtax for metafield
Hey @Servitel - this is a really great question,. I was able to get in touch with our product team to clarify this for you and I do have an answer/explanation. My understanding is that the response you’d receive when you create a product with metafields will not surface the metafields as a property in the response JSON body, but that the metafields should still be “attached” to the product.
To confirm this, you can make a GET call on the /admin/api/2023-01/products/PRODUCT_ID/metafields.json endpoint and it should confirm if the metafields have been added successfully. I definitely understand where you’re coming from here though. The documentation is a little unclear. I’ve made a note to see if we can push an update to the docs to make the workflow and expected responses more comprehensible.
Hope this helps - let us know if you still continue to see issues, happy to keep looking into this with you.