Solved

metafieldsSet mutation issues

ElRuberino
Shopify Partner
7 0 5

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?

Accepted Solution (1)

csam
Shopify Staff (Retired)
267 40 51

This is an accepted solution.

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.

 

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 10 (10)

csam
Shopify Staff (Retired)
267 40 51

This is an accepted solution.

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.

 

To learn more visit the Shopify Help Center or the Community Blog.

ElRuberino
Shopify Partner
7 0 5

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!

odeyan
Tourist
6 0 5

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

ElRuberino
Shopify Partner
7 0 5

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.

odeyan
Tourist
6 0 5

What I doing wrong???

Screen Shot 2021-08-02 at 14.55.07.png

ElRuberino
Shopify Partner
7 0 5

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

csam
Shopify Staff (Retired)
267 40 51

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 🙂 

21-08-czrsl-jyi09

To learn more visit the Shopify Help Center or the Community Blog.

odeyan
Tourist
6 0 5

@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:

Screen Shot 2021-08-05 at 14.45.06.png

 

ElRuberino
Shopify Partner
7 0 5

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"
    }
  ]
}
odeyan
Tourist
6 0 5

@ElRuberino Thank you man! 
It works now!