A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi all,
I am trying to upload some files from our server to our Shopify store using the GraphQL api.
I am following this guide from the official documentation: https://shopify.dev/api/examples/product-media
aswell as this tutorial: https://dev.to/fatihsamur/bulk-product-upload-on-shopify-using-graphql-admin-api-with-php-33ki
The query seems to be executing and I am getting this response back:
{
"data":{
"stagedUploadsCreate":{
"stagedTargets":[
{
"url":"https:\/\/shopify.s3.amazonaws.com\/tmp\/984219684\/products\/33057b4b-0c1c-47ee-89e9-0fbd718d2ad6\/68-07-60459-196_ls1.jpg?x-amz-acl=private&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJYM555KVYEWGJDKQ%2F20220913%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220913T085635Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=3b8592fd45e9214d6bff4a4bff7b098b3ac9959f6cc9057b0c5f3638dbbb9ed7",
"resourceUrl":"https:\/\/shopify.s3.amazonaws.com\/tmp\/984219684\/products\/33057b4b-0c1c-47ee-89e9-0fbd718d2ad6\/68-07-60459-196_ls1.jpg",
"parameters":[
{
"name":"content_type",
"value":"image\/jpg"
},
{
"name":"acl",
"value":"private"
}
]
}
],
"userErrors":[
]
}
},
"extensions":{
"cost":{
"requestedQueryCost":11,
"actualQueryCost":11,
"throttleStatus":{
"maximumAvailable":2000,
"currentlyAvailable":1989,
"restoreRate":100
}
}
}
}
I am now at the curl stage of the official shopify documentation.
I noticed that most of the curl parameters that I required were actually in the "url" part of my response.
So after untangling them I also noticed that I am missing several parameters and seem to have several new ones, for example the "AWSAccessKeyId" is not present but I have instead a "X-Amz-SignedHeaders" parameter, those are just a few examples.
I am not even sure why I am not receiving the response the same way as in this tutorial: https://dev.to/fatihsamur/bulk-product-upload-on-shopify-using-graphql-admin-api-with-php-33ki (because it seems strange that I have to untangle the parameters from the url).
I am quite lost on how to proceed with the curl multiform part and would appreciate any help.
I am new to GraphQL so please forgive me as I am still learning 🙂
Thanks in advance,
Matthias
Solved! Go to the solution
This is an accepted solution.
So im still working on this however, I managed to get the correct response.
I was silly and not following the correct Curl format found here: https://shopify.dev/api/admin-graphql/2022-07/mutations/stageduploadscreate
'{
"query": "mutation stagedUploadsCreate($input: [StagedUploadInput!]!) { stagedUploadsCreate(input: $input) { stagedTargets { url, resourceUrl parameters { name value } } } }",
"variables": {
"input": [
' . $inputVARIABLE . '
]
}
}'
I hope this helped someone :), the programming language is php.
Cheers,
Matthias
This is an accepted solution.
So im still working on this however, I managed to get the correct response.
I was silly and not following the correct Curl format found here: https://shopify.dev/api/admin-graphql/2022-07/mutations/stageduploadscreate
'{
"query": "mutation stagedUploadsCreate($input: [StagedUploadInput!]!) { stagedUploadsCreate(input: $input) { stagedTargets { url, resourceUrl parameters { name value } } } }",
"variables": {
"input": [
' . $inputVARIABLE . '
]
}
}'
I hope this helped someone :), the programming language is php.
Cheers,
Matthias
So...I am still struggling with the CURL part, and would appreciate any help.
I am constructing my CURL like so in postman based off of the POST request in https://shopify.dev/api/examples/product-media#upload-the-asset,
I am trying to run it through Postman and the curl functions in PHP both to no avail.
I am trying to send with x-amz-signatures too however, that seems to make no difference, and I still end with the same conflict of acl, policy error.
If anyone has experienced a similar hold-up I would appreciat ethem sharing their experience/how they managed to resolve their problem 🙂
Cheers,
Matthias