clj-http

erwinrooijakkers 2020-04-15T13:00:41.001100Z

How to upload multipart params? When I do

(deftest ^:integration upload-csv-test
  (is (= (http/post "<http://127.0.0.1:3333>"
                    [{:multipart {:name "file" :content (io/file (io/resource "valid.csv"))}}])
         nil)))
I get error: java.lang.IllegalArgumentException: Key must be integer

borkdude 2020-04-15T13:02:20.001700Z

@erwinrooijakkers you need to unwrap the outer vector and pass the arguments to :multipart in a vector

erwinrooijakkers 2020-04-15T13:03:59.002100Z

Oh thanks, yes I had that, different error 🙂:

erwinrooijakkers 2020-04-15T13:04:50.002700Z

(deftest ^:integration upload-csv-test
  (is (= (http/post "<http://127.0.0.1:3333>"
                    {:multipart [{:name "file" :content (io/file (io/resource "valid.csv"))}]})
         nil)))

;; =&gt; error: java.lang.Exception: Multipart content cannot be nil

borkdude 2020-04-15T13:06:53.003100Z

this indicates that (io/resource "valid.csv") returned nil

erwinrooijakkers 2020-04-15T13:06:59.003300Z

I see

erwinrooijakkers 2020-04-15T13:07:20.003500Z

Okay I get another 500 now

erwinrooijakkers 2020-04-15T13:07:27.003900Z

When running from cider test/resources are not included

erwinrooijakkers 2020-04-15T13:07:36.004200Z

Thanks now I get the error from the application itself 🙂

erwinrooijakkers 2020-04-15T13:33:18.004400Z

Works

erwinrooijakkers 2020-04-15T13:33:22.004700Z

Thanks @borkdude