Why am I getting a 400: Unsupported query with the files API?

I’m trying to test requests made to the Monday.com files API, and so far, I can’t any queries to successfully go through. I keep getting a 400: Unsupported query with all my attempts.

Here’s what I have in Postman:

image

And here’s the full query in text:
mutation ($file: File!) { add_file_to_column (file: $file, item_id: 8..., column_id: "files") { id } }

Yet when I run that (and any variations I can think of), I get the following response:

image

Also, for what it’s worth, I’m 100% sure that an item with the specified ID exists in our Monday.com system. I’m also sure that the Authorization token is fine because I’ve been using it to make valid requests to the regular Monday.com API.

Can anyone please point out what I’m doing wrong? Thank you.

For what it’s worth, I was able to get this to work by manually assembling the POST data in PHP with POST multipart/form-data boundaries and cURL. It wasn’t fun, but it worked.

What I can’t understand is why that method worked, but posting from Postman with the exact same data doesn’t and also trying to use Guzzle in Laravel with the same parameters didn’t work. Very strange.

I’m probably overlooking something obvious, but for anyone else using PHP that gets stuck, try manually assembling the POST fields with cURL to send the file request.

I used this SO post for reference purposes: curl - Send file using multipart/form-data request in php - Stack Overflow

Good luck! And let’s hope that the Monday.com API team makes this easier in the future (without breaking the currently working method) for all of our sakes.

Is there a missing permission somewhere that could explain this?
In the account there is an option for that :
https://YOUR_ACCOUNT_NAME.monday.com/admin/permissions/permissions

Hey @LOIJon - welcome to the community!

That’s a bit odd…I just tried running this in Postman and the query worked:

mutation ($file: File!) {add_file_to_column (file: $file, item_id: xxxx, column_id: "files") {id}}

You’ll want to make sure the ‘variables’ key is set to file, and that you are uploading as ‘form-data’:

-Daniel

2 Likes

Perhaps permissions are an issue, but I’m not sure how they could be if the token works for other API requests and I was able to use the token for the files by manually assembling the POST data in PHP.

Thanks for the reply, Daniel. I legitimately don’t know either. I cut it off in the screenshot, but I was attempting form-data and the variables[file] key was definitely set to an actual file. In other words, not sure why it didn’t work for me.

Hey @LOIJon - just to confirm, is this working now?

-Daniel

No, sadly, Daniel, it’s still not working. I tried exactly what you said, and I get an unsupported query error. Here’s the exact query I’m using (with the item ID removed):

mutation ($file: File!) {add_file_to_column (file: $file, item_id: xxxxxxxxx, column_id: "files") {id}}

I’m using form-data for the body data type in Postman, I’m posting to the correct URL, I’ve got the variables[file] parameter set to an actual file as you suggested, etc., etc. and it just doesn’t work.

It still works when I manually assemble a cURL query in PHP, but it doesn’t work in Postman. Sorry.

Hey @LOIJon - this is really odd. I’m wondering if perhaps Postman is / isn’t doing something in the headers. Could you send us a screenshot of the full config (with the API key blurred out)?

-Daniel

Sure, Daniel. This is what I’m doing:

And the response:

image

Hi :raising_hand_man:t2:
I notice that your version of Postman does not have a dedicated GraphQL radio-button for your post data.
Maybe you could try to run the query on a more recent version of Postman that have this feature and see if it helps.
it could be something with the headers, like @dsilva pointed out :thinking:

1 Like

I’m sorry for my last post about GraphQL radio-button in Postman.
Actually I tried what is described here Why am I getting a 400: Unsupported query with the files API? - #6 by dsilva and it work perfectly.

I had 500 error until i changed the variables[file] dropdown from text to file.

1 Like

Thanks, ellis. While it wasn’t clear in the screenshot, the variables[file] param value is being set via File, not Text. I selected File, and then searched my PC for a random image I wanted to upload. Still doesn’t work. I will try upgrading Postman and see if that matters, but I can’t imagine why it would and I have run out of ideas for why it’s not working for me.

ellis, thanks for your input. I upgraded Postman and that did indeed solve my problem. I left everything else the same and it worked. Thank you.

1 Like

Great catch @ellis! I’m glad this resolved the problem.

-Daniel

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.