def upload_attachments!(path, data)
      raise_exceptions = !!data.delete(:attachments_exception)
      attachments = [data.delete(:attachments)].flatten.compact
      return if attachments.empty?

      # retrieve the upload configuration for this record from ITRP
      storage = @client.get(path =~ /\d+$/ ? path : "#{path}/new", {attachment_upload_token: true}, @client.send(:expand_header))[:storage_upload]
      report_error("Attachments not allowed for #{path}", raise_exceptions) and return unless storage

      # upload each attachment and store the {key, filesize} has in the note_attachments parameter
      data[attachments_field(path)] = attachments.map {|attachment| upload_attachment(storage, attachment, raise_exceptions) }.compact.to_json
    end
def upload_attachments!(path, data)
      raise_exceptions = !!data.delete(:attachments_exception)
      attachments = [data.delete(:attachments)].flatten.compact
      return if attachments.empty?

      # retrieve the upload configuration for this record from ITRP
      storage = @client.get(path =~ /\d+$/ ? path : "#{path}/new", {attachment_upload_token: true}, @client.send(:expand_header))[:storage_upload]
      report_error("Attachments not allowed for #{path}", raise_exceptions) and return unless storage

      # upload each attachment and store the {key, filesize} has in the note_attachments parameter
      data[attachments_field(path)] = attachments.map {|attachment| upload_attachment(storage, attachment, raise_exceptions) }.compact.to_json
    end
upload the attachments in :attachments to ITRP and return the data with the uploaded attachment info