Upload Images using GraphQl

Hi,

To create new products, I have to use the productSet API, but I must first upload the images via FileCreate and retrieve the media IDs.

the problem when I create all the images of the new products, I cannot map between the data ‘fileCreate’ returned by API, and the images ID in my ERP.

My question, does Shopify respect the order of media created in the API response?

Exemple: is the image indexed 3 in the table sent in the API is that of the image indexed 3 in the DATA response table?

Thank you

Hi @kissa14

I’m not sure if the order is followed, but you can try using the id returned in the fileCreate API to call productSet and fill in the mediaIds

{
  "synchronous": true,
  "input": {
    "title": "T-product-3--2",
    "descriptionHtml": "

asf12121212asdfa儿童瓦尔塔玩儿森岛帆高阿萨法阿萨法ertwetwrtwtwertwtwrtwet66465`13121212121

\n",
    "productType": "xq",
    "handle": "t-product-3--2",
    "status": "ACTIVE",
    "tags": "xq1",
    "productOptions": [
      {
        "name": "size",
        "values": [
          {
            "name": "m"
          },
          {
            "name": "s"
          },
          {
            "name": "l"
          }
        ]
      },
      {
        "name": "color",
        "values": [
          {
            "name": "black"
          },
          {
            "name": "red"
          },
          {
            "name": "pink"
          }
        ]
      }
    ],
    "variants": [
      {
        "price": "13.32",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "l"
          },
          {
            "optionName": "color",
            "name": "pink"
          }
        ]
      },
      {
        "price": "13.11",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "l"
          },
          {
            "optionName": "color",
            "name": "red"
          }
        ]
      },
      {
        "price": "13.11",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "l"
          },
          {
            "optionName": "color",
            "name": "black"
          }
        ]
      },
      {
        "price": "11.23",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "s"
          },
          {
            "optionName": "color",
            "name": "black"
          }
        ]
      },
      {
        "price": "11.23",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "s"
          },
          {
            "optionName": "color",
            "name": "pink"
          }
        ]
      },
      {
        "price": "11.11",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "s"
          },
          {
            "optionName": "color",
            "name": "red"
          }
        ]
      },
      {
        "price": "11.11",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "m"
          },
          {
            "optionName": "color",
            "name": "pink"
          }
        ]
      },
      {
        "price": "11.11",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "m"
          },
          {
            "optionName": "color",
            "name": "red"
          }
        ]
      },
      {
        "price": "11.2",
        "sku": "39549861654646-1",
        "optionValues": [
          {
            "optionName": "size",
            "name": "m"
          },
          {
            "optionName": "color",
            "name": "black"
          }
        ]
      }
    ],
  "mediaIds": [
   "gid://shopify/MediaImage/39306318807315"
  ]
  }
}

Hi @kissa14

I have passed this along to the relevant team and they will get back to you

2 Likes

hi @Kyle_liu

Thank you for your response, but in my case I work with bulk products.