metafieldsSet mutation issues

Hi, has anyone had any luck with the metafieldsSet mutation?

https://shopify.dev/api/admin/graphql/reference/metafields/metafieldsset?api%5Bversion%5D=unstable

Every time I try this I get an INTERNAL_SERVER_ERROR with a requestId but no error information. I’ve sent it to Shopify but had no reply yet. So I’m wondering if anyone’s ever actually managed to get this working?

It’s on the unstable API channel but it should still be usable, right?

Hi @ElRuberino

Taking a look at the unstable metafieldsSet mutation, it may be possible that some error handling is missing for certain types of errors. For any calls made to the unstable version of the API, I would recommend adhering strictly to the new definitions of types, and avoiding any deprecated types.

You can see the currently valid types here: https://shopify.dev/apps/metafields/definitions/types

I’ll follow up with you as well via your support ticket, as I’m not 100% certain of the cause of the errors you’ve been receiving.

1 Like

Hi @csam , thanks for getting back to me mutli-channel!

I’ve replied to your email but just for anyone else who finds this…

Yes, it was the new types - needed json instead of json_string. The complication was that the error message didn’t contain any information, but that’s only to be expected with an unstable version of the API.

All sorted, thanks!

2 Likes

Hi man!
Did you solve the metafieldsSet problem?
Could you be so kind to share the solution (mutation and input) please?

1 Like

Hi @odeyan

The mutation and input are exactly as described in the docs.

The issue I was having was that the type param used to be called valueType, and the possible values have changed. If you take a look at the link in the accepted answer, that has the mapping from the old valueType to the new type.

Do shout if that doesn’t solve your issues.

What I doing wrong???

1 Like

You’re using the 2021-07 version of the API - this mutation only exists in the unstable version

Not sure if you can do that in the graphql explorer, but the endpoint is: https://{{ store_name }}.myshopify.com/admin/api/unstable/graphql.json

2 Likes

Hi @odeyan

As @ElRuberino mentioned, you will need to use the unstable version of the API, as this feature is still being developed and is not officially released. It is possible to access this through the GraphiQL app :slightly_smiling_face:

1 Like

Hi guys @csam @ElRuberino
Tanks a lot for your answers!
It really solved the mutation error but now the next problem in input code.
Could you please show the example of correct input code? Because I tried everything ))
This is one of my try down below:

Your variables are wrong. Are you looking at the right docs?

It should look like this:

{
  "metafields": [
    {
      "ownerId": "Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE=",
      "namespace": "placeholder",
      "key": "placeholder",
      "value": "placeholder",
      "type": "placeholder"
    }
  ]
}
1 Like

@ElRuberino Thank you man!
It works now!

1 Like