metafieldsSet mutation issues

Solved
ElRuberino
Tourist
6 0 4

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?

0 Likes
csam
Shopify Staff
Shopify Staff
131 19 21

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.

 

CS | API Support @ 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

ElRuberino
Tourist
6 0 4

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 2

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

0 Likes
ElRuberino
Tourist
6 0 4

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.

0 Likes
odeyan
Tourist
6 0 2

What I doing wrong???

Screen Shot 2021-08-02 at 14.55.07.png

0 Likes
ElRuberino
Tourist
6 0 4

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
Shopify Staff
131 19 21

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

CS | API Support @ 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

odeyan
Tourist
6 0 2

@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

 

0 Likes
ElRuberino
Tourist
6 0 4

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"
    }
  ]
}