lib/nylas/utils/file_utils.rb in nylas-6.0.0.beta.2 vs lib/nylas/utils/file_utils.rb in nylas-6.0.0.beta.3

- old
+ new

@@ -9,12 +9,17 @@ # @param request_body The values to create the message with. # @return The form data to send to the API and the opened files. # @!visibility private def self.build_form_request(request_body) attachments = request_body.delete(:attachments) || request_body.delete("attachments") || [] - message_payload = request_body.to_json + # RestClient will not send a multipart request if there are no attachments + # so we need to return the message payload to be used as a json payload + return [request_body, []] if attachments.empty? + # Prepare the data to return + message_payload = request_body.to_json + form_data = {} opened_files = [] attachments.each_with_index do |attachment, index| file = attachment[:content] || attachment["content"]