I want to create a page via the rest api. I want to set the meta description while creating the page via api. How can i pass the data?
When creating a page via the Shopify REST API, you can try to set the meta description by including it within the metafields attribute of your POST request. Here’s how you can try and structure the JSON data in your API call:
{
"page": {
"title": "Your Page Title",
"body_html": "
Your HTML content here
",
"metafields": [
{
"namespace": "global",
"key": "description_tag",
"value": "Your meta description here",
"type": "string"
}
]
}
}
No idea if this will work, the documentation is vague on this.
Yes, i got the solution. I tried a different method like i have updated it with the meta field api.
Post data for the api is :
[
‘key’ => ‘description_tag’,
‘value’ => “content”,
‘namespace’ => ‘global’,
‘type’ => ‘string’
]
Endpoint url -
https://baseurl/admin/api/2023-01/pages/pageid/metafields.json
method : POST
It worked !!!
I think your method will also work.
Yes, i got the solution. I tried a different method like i have updated it with the meta field api.
Post data for the api is :
[
‘key’ => ‘description_tag’,
‘value’ => “content”,
‘namespace’ => ‘global’,
‘type’ => ‘string’
]
Endpoint url -
https://baseurl/admin/api/2023-01/pages/pageid/metafields.json
method : POST
It worked !!!
Awesome, glad you figured it out!!!
