Solved

Updating Product SEO Description using Rest API

fragranzaUk
Excursionist
21 0 3

Hi,

I have uploaded 18K products with custome SEO description. Now I would like to change/improve the SEO description using REST API. I had a look in to the documentations but I could not figure it out. 

This is the call I am making for product id 6155434229913:

 

https://XXXXX.myshopify.com/admin/api/2021-01/products/6155434229913/metafields.json

 

I am using PUT request sending following JSON:

 

{ 
product 
 { 
description_tag = seoDescription 
}
 } 

But the SEO description is not getting updated. Please let me know what I am doing wrong here.

Thanks

 

 

Accepted Solution (1)

Jayvin
Shopify Partner
284 42 89

This is an accepted solution.

Hi,

Using rest api it will be like this:

1. Get the metafields of the product: https://XXXXX.myshopify.com/admin/api/2021-01/products/6155434229913/metafields.json
2. Filter the metafields above with namespace="global" and key="description_tag"
3. If you have found the metafield in the step above, update the value with the new SEO description_tag
4. Update using this endpoint => https://shopify.dev/docs/admin-api/rest/reference/metafield#update-2021-01, use the existing metafield id from above
5. If the metafield has not been found at step 2, then create a new one https://shopify.dev/docs/admin-api/rest/reference/metafield#create-2021-01 (Create a new metafield for a Product resource)

That's it.

banned

View solution in original post

Replies 2 (2)

Jayvin
Shopify Partner
284 42 89

This is an accepted solution.

Hi,

Using rest api it will be like this:

1. Get the metafields of the product: https://XXXXX.myshopify.com/admin/api/2021-01/products/6155434229913/metafields.json
2. Filter the metafields above with namespace="global" and key="description_tag"
3. If you have found the metafield in the step above, update the value with the new SEO description_tag
4. Update using this endpoint => https://shopify.dev/docs/admin-api/rest/reference/metafield#update-2021-01, use the existing metafield id from above
5. If the metafield has not been found at step 2, then create a new one https://shopify.dev/docs/admin-api/rest/reference/metafield#create-2021-01 (Create a new metafield for a Product resource)

That's it.

banned

fragranzaUk
Excursionist
21 0 3

Hi,

I manage to get it working. 

Need to get Meta ID first, then use PUT requests to update Meta description. 

 

Thanks