Adding file to column via v2 API

Hi,

Trying unsuccessfully to upload a file to an existing column following the API docs, but I receive a Bad Request error without too much information regarding what is bad.

I’m working with Python, first I generate a request data:

req_data = “”“mutation{
add_file_to_column(item_id: %s, column_id: “%s”, $file: “%s”) {
id
}
}”"" % (item_id, column_id, self.to_base_64(fpath))

The file path is opened and then converted to a base64 string, this is the final request:

mutation {
add_file_to_column(
item_id: 724825528
column_id: “Files”
$file: “LHByb2plY3RfbmFtZSxncm91cAowLGJhdHJ1LAoxLGJpc2Vhc2ssCjIsY2JjZGFpcnlpbCwKMyxjY2JvdHRsZXJzdXMsCjQsY2Nici1wcm9kLAo1LGNjbGliZXJ0eXVzLAo2LGNjdHJhZG14LAo3LGRpYWdlb2FyLAo4LGRpYWdlb2JlbmVsdXgsCjksZGlhZ2VvaW4sCjEwLGRpYWdlb2l0LAoxMSxkaWFnZW9rZSwKMTIsZGlhZ2VvbXgsCjEzLGRpYWdlb25nLAoxNCxkaWFnZW9ub3JkaWNzLAoxNSxkaWFnZW9ydSwKMTYsZ3NrbnosCjE3LGluYmV2Y2ksCjE4LGluYmV2bmwsCjE5LGluYmV2dHJhZG14LAoyMCxtb25kZWxlemRtaXVzLAoyMSxuZXN0bGVpbCwKMjIscG5nanAsCjIzLHJpbmllbHNlbnVzLGdyb3VwX2EKMjQscmluaWVsc2VudXMsZ3JvdXBfYgoyNSxyaW5pZWxzZW51cyxncm91cF9jCjI2LHJpbmllbHNlbnVzLGdyb3VwX2QKMjcscmluaWVsc2VudXMsZ3JvdXBfZQoyOCxyd2ZhaXJwcnNnLGdyb3VwX2EKMjksc2Fub2ZpY2ksCjMwLHNhbm9maWNtLAozMSxzYW5vZmlqcCwKMzIsc2Fub2ZpbnosCjMzLHNhbm9maXNuLAozNCxzYW5vZml0ciwKMzUsc2h1ZmVyc2FsaWwsCg==”
) {
id
}
}

I am sending it as a POST to the /v2/file API, I can add items and do other manipulations, it’s just that this query keep failing with Bad Request.
I tried omitting the $ in $file, tried escaping it, nothing worked.

Thanks.

Hey @aviadm - welcome!

Right now you wouldn’t be able to upload the file this way - it would need to be sent over as a multipart file. We’re working on having more documentation on this, but in the meanwhile I would recommend following this guide from our community.

Let me know if we can help with anything else.

-Daniel