I am attempting to add an attachment to an Asana task.
My JSON request body is as follows:
request_body = {
"data" => {
"file" => "@#{attachment.tempfile}"
}
}
I receive this output on the POST:
error: file: File is not an object
The "attachment" variable is a regular rails form attachment.
Any ideas?
-----EDIT-----
For anyone looking in the future, I figured it out using the Faraday gem. Here is the code I used:
connection = Faraday.new(:url => @uri) do |conn|
conn.response :logger
conn.request :multipart
conn.request :url_encoded
conn.basic_auth(@api_key, '')
conn.adapter :net_http
end
payload = { :file => Faraday::UploadIO.new(file, file_type) }
response = connection.post(@uri, payload)
return response