clj-commons / manifold

A compatibility layer for event-driven abstractions
1.02k stars 106 forks source link

Multipart upload fails with aleph, works fine with clj-http #198

Closed anuj-seth closed 3 years ago

anuj-seth commented 3 years ago

Hi, I am trying to do a multipart upload which fails with aleph but succeeds with clj-http. Below is a minimal piece of code which reproduces the problem though I have redacted the Hubspot API Key. The commented out code using clj-http works fine. Do I need to take some special care while doing multipart uploads with aleph ? Thanks, Anuj Seth.

  (require '[clj-http.client :as client])
  (require '[aleph.http :as aleph])
  (require '[clojure.java.io :as io])
  (require '[cheshire.core :as json])

    (let [column-mappings [{"ignored" false
                          "columnName" "Company ID"
                          "idColumnType" "HUBSPOT_OBJECT_ID"
                          "propertyName" nil
                          "foreignKeyType" nil
                          "columnObjectTypeId" "0-2"
                          "associationIdentifierColumn" false}
                         {"ignored" false
                          "columnName" "site_sessions_30d",
                          "idColumnType" nil
                          "propertyName" "site_sessions_30d",
                          "foreignKeyType" nil
                          "columnObjectTypeId" "0-2",
                          "associationIdentifierColumn" false}]
        import-request {"name" "test_import"
                        "files" [{"fileName" "TestData.csv"
                                  "fileFormat" "CSV"
                                  "fileImportPage" {"hasHeader" true
                                                    "columnMappings" column-mappings}}]}]
    @(aleph/post "https://api.hubapi.com/crm/v3/imports?hapikey=<<INSERT API KEY HERE>>"
                 {:multipart [{:name "files"
                               :content (io/file "/home/anuj/TestData.csv")}
                              {:name "importRequest"
                               :content (json/generate-string import-request)}]})
    ;; (client/post "https://api.hubapi.com/crm/v3/imports?hapikey=<<INSERT API KEY HERE>>"
    ;;              {:multipart [{:name "files"
    ;;                            :content (io/file "/home/anuj/TestData.csv")}
    ;;                           {:name "importRequest"
    ;;                            :content (json/generate-string import-request)}]})
    )
anuj-seth commented 3 years ago

Opened in wrong repo. Moving this to aleph