clj-http

d._.b 2024-03-07T17:21:37.639479Z

I'm converting from hato to clj-http (don't ask), and multipart is not working for me no matter what I do

d._.b 2024-03-07T17:23:42.482529Z

In hato, it's just :multipart [{:name "request_body" :content-type "form-data" :content (json/encode body)}] in clj-http im trying: :multipart [{:name "request_body" :content (json/encode body) :encoding "UTF-8" :mime-type "form-data"}]

mmer 2024-03-07T17:30:56.485219Z

This works for me:

(http/post url
                  {:client client
                   :headers {"Accept" "application/json"
                             ...}
                   :multipart [{:name "file" :content content
                                :file-name filename}]})

d._.b 2024-03-07T17:37:14.365829Z

maybe i don't understand multipart -- what is the filename here?

mmer 2024-03-07T17:41:52.003859Z

I just set it to the filename of the file I am sending in the content. It is just the filename not the path.

mmer 2024-03-07T17:42:08.593059Z

What is the error you are getting?

d._.b 2024-03-07T17:43:16.473479Z

that the server has an error reteiving a part of the multipart message

d._.b 2024-03-07T17:43:42.097039Z

so not very specific

d._.b 2024-03-07T17:43:55.374649Z

but hato Just Works, and im struggling to get clj-http to work

mmer 2024-03-07T17:46:32.468179Z

I may have answered incorrectly as I was using clj-http - and moved to use babashka.http-client as I am using bb. Sorry, I may not be the best to answer this.

d._.b 2024-03-07T18:08:24.525549Z

no problem, thanks

d._.b 2024-03-07T20:07:04.469259Z

It looks like hato includes: content-type: multipart/form-data; boundary=hatoBoundarynSKqshIB6Wf6VnFhxnWPdnY6rkS2nH in the headers whereas clj-http does not

d._.b 2024-03-07T20:08:22.029609Z

i guess that brings up the question: how do i set the boundary if im manually handling content type?