Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
I'm creating private metafields to be used by my public app. When I try making a test mutation and query within Shopify GraphiQL App:
mutation ($input: PrivateMetafieldInput!) { privateMetafieldUpsert(input:$input) { privateMetafield { namespace key value valueType } userErrors { field message } } } { "input": { "namespace": "testNamespace", "key": "testKey", "valueInput": { "value": "testValue", "valueType": "STRING" } } }
I receive the following response:
{ "message": "The server responded with invalid JSON, this is probably a server-side error", "response": "<!DOCTYPE html>\n<html>\n<head>\n <title>The change you wanted was rejected (422)</title>\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <style>\n .rails-default-error-page {\n background-color: #EFEFEF;\n color: #2E2F30;\n text-align: center;\n font-family: arial, sans-serif;\n margin: 0;\n }\n\n .rails-default-error-page div.dialog {\n width: 95%;\n max-width: 33em;\n margin: 4em auto 0;\n }\n\n .rails-default-error-page div.dialog > div {\n border: 1px solid #CCC;\n border-right-color: #999;\n border-left-color: #999;\n border-bottom-color: #BBB;\n border-top: #B00100 solid 4px;\n border-top-left-radius: 9px;\n border-top-right-radius: 9px;\n background-color: white;\n padding: 7px 12% 0;\n box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n }\n\n .rails-default-error-page h1 {\n font-size: 100%;\n color: #730E15;\n line-height: 1.5em;\n }\n\n .rails-default-error-page div.dialog > p {\n margin: 0 0 1em;\n padding: 1em;\n background-color: #F7F7F7;\n border: 1px solid #CCC;\n border-right-color: #999;\n border-left-color: #999;\n border-bottom-color: #999;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-top-color: #DADADA;\n color: #666;\n box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n }\n </style>\n</head>\n\n<body class=\"rails-default-error-page\">\n <!-- This file lives in public/422.html -->\n <div class=\"dialog\">\n <div>\n <h1>The change you wanted was rejected.</h1>\n <p>Maybe you tried to change something you didn't have access to.</p>\n </div>\n <p>If you are the application owner check the logs for more information.</p>\n </div>\n</body>\n</html>\n" }
When I make the same request using Postman everything is just fine:
The only thing I can think of is that Shopify GraphiQL App doesn't have the private app api access token that Postman has so would that be something I would assign within the server.js (I followed the "Create a Shopify App with React and Node) or is there another way to handle that private access token to allow my public app to create a private metafield on the shop resource? Am I just way out in the woods on this?
Hey Jenn,
Liam here from Shopify - thanks for getting in touch about this. To help troubleshoot why you can make mutations and query the metafields with Postman, but not with GraphiQL, we'd need to know which version of the API are you using? It's possible that the version you are using could be unstable.
Cheers,
Liam
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
@Liam, hello! I am using the latest, 2019-10, version of Shopify GraphiQL.
Hey @jenn11
I've asked our internal dev team to troubleshoot this and they were able to run the same query in GraphiQL. There could be something auth-related happening here. Could you try restarting your admin session and attempting again? If you're still seeing this issue, you can private message me your .myshopify.com URL and we can look at logs from our side.
Cheers,
Liam
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi,
Can you please share what the solution to this problem was?
I am creating a private metafield via the productCreate mutation, and in the response I can see the private metafield has been created.
When I bulk read the products afterwards and fetch the private metafields, I get an empty list. Maybe my issue is related to the issue in this thread?
Thanks,
-Louise