A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I am trying to set a metafield on some products, that may have multiple options, like the image attached.
My code is the following:
value = ['test','test2']
But this is not working. Documentation has no examples on such case. Any ideas?
Solved! Go to the solution
This is an accepted solution.
Hi @B3th3sd4 ,
It appears that you're trying to pass a Python array as the metafield value, which is not the best idea since the API would expect all attributes to be strings. Have you tried converting your array to a proper JSON array literal?
This is an accepted solution.
As MetafieldsGuru already helpfully explained, the value should always be passed as a String. In Python, you can use the json.dumps method to convert your Array value to a JSON String.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hi @B3th3sd4 ,
It appears that you're trying to pass a Python array as the metafield value, which is not the best idea since the API would expect all attributes to be strings. Have you tried converting your array to a proper JSON array literal?
Thank you very much. I should expect that since all the API is JSON oriented.
This is an accepted solution.
As MetafieldsGuru already helpfully explained, the value should always be passed as a String. In Python, you can use the json.dumps method to convert your Array value to a JSON String.
To learn more visit the Shopify Help Center or the Community Blog.
Did you get a solution? If so please add the python code.