diff --git a/exporter/src/app/consumer/api.cljs b/exporter/src/app/consumer/api.cljs index 2c0f6ea654..f7c7ffa93e 100644 --- a/exporter/src/app/consumer/api.cljs +++ b/exporter/src/app/consumer/api.cljs @@ -69,11 +69,14 @@ :response body))))))))) (defn- request - "POST `params` to a management method as transit+json." + "POST `params` to a management method as transit+json. The content + type travels on every call: without it the backend never parses the + body as transit and validates an empty map." [method params] (->> (fetch (method-uri method) #js {:method "POST" - :headers (shared-key) + :headers (doto (shared-key) + (unchecked-set "Content-Type" "application/transit+json")) :body (t/encode-str params) :dispatcher (dispatcher)}) (p/mcat parse-response))) diff --git a/exporter/test/exporter_tests/api_test.cljs b/exporter/test/exporter_tests/api_test.cljs index b2953659ba..3fae29bd9f 100644 --- a/exporter/test/exporter_tests/api_test.cljs +++ b/exporter/test/exporter_tests/api_test.cljs @@ -95,6 +95,19 @@ restore! done)))) +(t/deftest json-calls-declare-the-transit-content-type + ;; without it the backend never parses the body as transit and + ;; validates an empty map (every key a `missing-key`) + (t/async done + (let [restore! (install-fetch!)] + (with-restore-and-done + (p/fmap (fn [_] + (t/is (= "application/transit+json" + (fetch-header "Content-Type")))) + (api/claim-job (uuid/next) "2026-10-07T00:00:00Z")) + restore! + done)))) + (t/deftest report-job-progress-posts-the-beat (t/async done (let [job-id (uuid/next)