A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
QUERY
mutation fileCreate($files: [FileCreateInput!]!) {
fileCreate(files: $files) {
files {
alt
createdAt
}
userErrors {
code
field
message
}
}
}
{
"files": [
{
"alt": "Rainbow hearts on watercolor canvas",
"originalSource": "https://cdn.shopify.com/s/files/1/0456/9399/2982/files/rainbow-wooden-hearts-lined-up-on-watercolour-canvas.jpg"
}
]
}
But I got this response. Am I missing something? Thanks in advance.
{
"data": {
"fileCreate": null
},
"errors": [
{
"message": "FileCreate access denied",
"locations": [
{
"line": 3,
"column": 3
}
],
"path": [
"fileCreate"
]
}
],
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 990,
"restoreRate": 50.0
}
}
}
}
Solved! Go to the solution
This is an accepted solution.
Hey @HendryRaudsepp - just wanted to confirm if the app access has been updated to include the correct access scope - write_files
- per our official API doc here? An app would need this scope access to successfully complete the mutation.
If you have updated your app include this and it's still not working as expected, please share an x-request-id header returned from a request where this occurs. I would be happy to take a closer look and pass on any insights - Cheers!
awwdam | 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
This is an accepted solution.
Hey @HendryRaudsepp - just wanted to confirm if the app access has been updated to include the correct access scope - write_files
- per our official API doc here? An app would need this scope access to successfully complete the mutation.
If you have updated your app include this and it's still not working as expected, please share an x-request-id header returned from a request where this occurs. I would be happy to take a closer look and pass on any insights - Cheers!
awwdam | 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
Hello, thanks for your answer. Now I can upload files using api. BTW - can you let me know how to get file ID ? When I try to update or delete file, api needs file ID. I have searched online for a long time, but I couldn't find a way. Would be great if I can learn that. Cheers. Hendry
Add these lines to your fileCreate query to the files { } section:
...on MediaImage {
id
}
...on GenericFile {
id
}