api - How to escape double quotes in shopify product metafield value?
I'm using curl in a php script to send an api request to shopify as described at https://shopify.dev/docs/admin-api/rest/reference/metafield?api%5Bversion%5D=2020-01#create-2020-10 (https://shopify.dev/docs/admin-api/rest/reference/metafield?api%5Bversion%5D=2020-01#create-2020-10). Specifically I'm sending the following to https://[user]:[pwd]@[store handle].myshopify.com/admin/api/2020-10/products/[product id]/metafields.json:
Array ( [metafield] => Array ( [namespace] => specs [key] => Length [value] => 2\" [value_type] => string ) )
And I get the error 422 Unprocessable Entity back from shopify. I also get the same error without the backslash before the double quote. If I replace the quote with the word inches it is added without any error. Is there a proper way to escape double quotes within metafield values in shopify?
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.