Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Internal error on ProductUpdate using media

Internal error on ProductUpdate using media

ShaneOH
Shopify Partner
21 1 8

Hi everybody!

 

I've received the following internal server error:

Internal error. Looks like something went wrong on our end. Request ID: edd30801-182a-4e3b-b391-c6045531bbcf-1720815148

I'm doing a productUpdate mutation as

mutation($input: ProductInput!, $mediaCount: Int!, $media: [CreateMediaInput!]) {
  productUpdate(input: $input, media: $media) {
    product {
      id
      publishedAt
      handle
      images(first: $mediaCount) {
        edges {
          node {
            id
            url
          }
        }
      }
      media(first: $mediaCount) {
        edges {
          node {
            id
            ... on MediaImage {
              id
              image {
                id
                url
              }
              mediaContentType
            }
          }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}

And the payload is

{
  "input": {
    "id": "gid:\/\/shopify\/Product\/8464475324628",
    "variants": [
      {
        "id": "gid:\/\/shopify\/ProductVariant\/45228910084308",
        "mediaId": "gid:\/\/shopify\/MediaImage\/33827789865172"
      },
      {
        "id": "gid:\/\/shopify\/ProductVariant\/45228910117076",
        "mediaId": "gid:\/\/shopify\/MediaImage\/34024068022484"
      },
      {
        "id": "gid:\/\/shopify\/ProductVariant\/45228910149844",
        "mediaId": "gid:\/\/shopify\/MediaImage\/33827789930708"
      }
    ]
  },
  "media": [
    {
      "originalSource": "https:\/\/assets.mysuredone.com\/688264\/media-pics\/shopifyvt1-95cca002faee61f16543f5830f4bd418ce82b835-3.jpeg",
      "mediaContentType": "IMAGE"
    }
  ],
  "mediaCount": 5
}

I'm using API_VERSION = '2023-10'

What am I doing wrong?

Thanks

Replies 2 (2)

Kyle_liu
Shopify Partner
421 53 76

Hi @ShaneOH 

 

Can you provide more information? I used your request data and it was successfully called

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me Email Me Buy Me A Coffee
ShaneOH
Shopify Partner
21 1 8

Hi @Kyle_liu the API is no longer returning above error, however when I do something like:

mutation($input: ProductInput!, $mediaCount: Int!, $media: [CreateMediaInput!]) {
  productUpdate(input: $input, media: $media) {
    product {
      id
      publishedAt
      handle
      images(first: $mediaCount) {
        edges {
          node {
            id
            url
          }
        }
      }
      media(first: $mediaCount) {
        edges {
          node {
            id
            ... on MediaImage {
              id
              image {
                id
                url
              }
              mediaContentType
            }
          }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}

with variables as:

"input": {
      "id": "gid:\/\/shopify\/Product\/8518244237524",
      "descriptionHtml": "abvwW",
      "options": [
        "Size"
      ],
      "title": "TEST-SHOPIFY-8-Parent",
      "variants": [
        {
          "mediaSrc": [
            "http:\/\/assets.mysuredone.com\/688264\/media-photos\/test-shopify-8-parent-b02f42467e431bde8449c488d6531a249a398f92-2.jpeg"
          ],
          "id": "gid:\/\/shopify\/ProductVariant\/45342159110356"
        },
        {
          "mediaSrc": [
            "http:\/\/assets.mysuredone.com\/688264\/media-photos\/test-shopify-8-vmedium-06d66716e1ba83c8296da6537ec74b64631feedf.jpeg"
          ],
          "id": "gid:\/\/shopify\/ProductVariant\/45342159143124"
        },
        {
          "mediaSrc": [
            "http:\/\/assets.mysuredone.com\/688264\/media-photos\/test-shopify-8-vlarge-8e898ef852fa42aaebc69b9c396225689395a7a0.png"
          ],
          "id": "gid:\/\/shopify\/ProductVariant\/45342159175892"
        }
      ]
    },
    "media": [
      {
        "originalSource": "http:\/\/assets.mysuredone.com\/688264\/media-photos\/test-shopify-8-parent-308768e148c18a13f58367cd70f62fde9d2260cd.jpeg",
        "mediaContentType": "IMAGE"
      },
      {
        "originalSource": "http:\/\/assets.mysuredone.com\/688264\/media-photos\/test-shopify-8-parent-b02f42467e431bde8449c488d6531a249a398f92-2.jpeg",
        "mediaContentType": "IMAGE"
      },
      {
        "originalSource": "http:\/\/assets.mysuredone.com\/688264\/media-photos\/test-shopify-8-vmedium-06d66716e1ba83c8296da6537ec74b64631feedf.jpeg",
        "mediaContentType": "IMAGE"
      },
      {
        "originalSource": "http:\/\/assets.mysuredone.com\/688264\/media-photos\/test-shopify-8-vlarge-8e898ef852fa42aaebc69b9c396225689395a7a0.png",
        "mediaContentType": "IMAGE"
      }
    ],
    "mediaCount": 4
  }

I'm seeing the media is correctly uploaded to the product but not attached to the existing variants, why?
Thanks