3D model uploaded through GraphQL API is failed to validate

Highlighted
Tourist
9 0 0

I want to upload a 3D model to a product page using GraphQL api. I followed the steps in this tutorial and managed to install graphiql editor in the development store as well. However, after I uploaded the 3D model to a specified product page and viewing the corresponding product in the browser, Shopify claims that the model was failed to validate. But I don't get any error in the graphql media create API response.

First,I do a staged upload:

 

mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {
stagedUploadsCreate(input: $input) {
stagedTargets {
resourceUrl
url
}
userErrors {
field
message
}
}
}

 

variables:

 

{
"input": [
{
"resource": "MODEL_3D",
"filename": "https://raw.githubusercontent.com/pavinduLakshan/model/master/original_glb.glb",
"mimeType": "model/gltf-binary",
"fileSize": "197172"
}
]
}

 

 

Then I do a product create media as follows using the resourceUri obtained in the above request.

 

mutation productCreateMedia($productId: ID!, $media: [CreateMediaInput!]!) {
  productCreateMedia(productId: $productId, media: $media) {
    media {
      alt
    }
    mediaUserErrors {
      code
      field
      message
    }
    product {
      id
    }
  }
}

 

 

variables:

 

{
  "productId": "gid://shopify/Product/5499834007719",
  "media": [
    {
      "originalSource": "https://storage.googleapis.com/threed-models-production/models/9dfef9c163e2fcc8/https_raw_githubusercontent_com_pavinduLakshan_model_master_original_glb.glb?external_model3d_id=bW9kZWwzZC00MDM5Mw==",
      "mediaContentType": "MODEL_3D"
    }
  ]
}

 

I don't get any error when uploading the 3D model:

image_2020_07_17T09_15_38_005Z.png

 

but in the corresponding product update page in the Shopify admin UI, I'm getting an error message like below.

media_invalid_3d_modal.PNG

Can someone please help me to understand why this error is happening? Thank you very much for the all helpful suggestions.

0 Likes