shopify multiple metafield update at one api call

shopify multiple metafield update at one api call

plcoje
Visitor
2 0 0

I want to update multiple metafields of product which is shown at my web site at one api call.

 

Url : https://{...}:{...}@{...}myshopify.com/admin/api/2021-07/products/{productID}/metafields.json 

 

const metafieldParam = {
metafield(s) : [
{
namespace : "Urls",
key : "image",
value : "",
type :
},
{
namespace : "Urls",
key : "video",
value : "",
type : "",
},
{
....
},
]
}

await fetch(url, {method : 'POST' , headers : {'Content-Type' : 'application/json', body:JSON.stringify(metafieldParam)})

but I get 400 bad request from shopify. 

 

If I send request by only one param ( ex : param = {metafield : { namespace : ... } } , It succeeds to update, but I want to update all metafields at one fetch call. Is this possible?

 

I tried these...

1. metafield(s) 

2. param = { product : { metafields : { .... }  }  },  

3. param = { product { id : product_id ,{ metafields : { .... }  }  } 

4. PUT

5. POST 

6. in url 2022-07

 

I appreciate your help !!!! 

Replies 2 (2)

Nyshawn
Shopify Partner
91 3 3

It's not possible to update multiple metafields at once. You will need to make a separate API call for each metafield you want to update.

banned
Umar-faro
Shopify Partner
1 0 0

Hi,

 

Is it possible to create multiple meta fields with the same key?

 

your help would be appreciated!!.