This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-01
Channels
- # announcements (2)
- # architecture (8)
- # babashka (21)
- # beginners (75)
- # calva (3)
- # clj-kondo (6)
- # cljdoc (6)
- # cljs-dev (10)
- # clojars (4)
- # clojure (94)
- # clojure-europe (12)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (6)
- # clojure-uk (4)
- # clojurescript (51)
- # community-development (13)
- # core-async (3)
- # css (1)
- # cursive (8)
- # datomic (7)
- # girouette (3)
- # graphql (3)
- # improve-getting-started (4)
- # integrant (2)
- # interop (5)
- # jobs (12)
- # kaocha (1)
- # lsp (24)
- # malli (4)
- # membrane (13)
- # nextjournal (9)
- # off-topic (6)
- # re-frame (9)
- # reitit (2)
- # remote-jobs (1)
- # reveal (4)
- # ring (4)
- # scittle (3)
- # shadow-cljs (4)
- # spacemacs (1)
- # testing (2)
- # vrac (1)
can someone explain to me why I’m seeing this error?
"res is " {:response {:status 400, :body "{\"spec\":\"(spec-tools.core/spec {:spec (clojure.spec.alpha/keys :req-un [:spec$34944/timezone :spec$34944/name]), :type :map, :leaf? false})\",\"problems\":[{\"path\":[],\"pred\":\"clojure.core/map?\",\"val\":null,\"via\":[],\"in\":[]}],\"type\":\"reitit.coercion/request-coercion\",\"coercion\":\"spec\",\"value\":null,\"in\":[\"request\",\"body-params\"]}", :headers {"Content-Type" "application/json; charset=utf-8", "X-XSS-Protection" "1; mode=block", "X-Frame-Options" "SAMEORIGIN", "X-Content-Type-Options" "nosniff"}}, :request {:protocol "HTTP/1.1", :remote-addr "127.0.0.1", :headers {"host" "localhost", "content-type" "application/x-www-form-urlencoded", "content-length" "39"}, :server-port 80, :content-length 39, :content-type "application/x-www-form-urlencoded", :uri "/api/schools", :server-name "localhost", :body #object[java.io.BufferedInputStream 0x79432e4b "[email protected]"], :scheme :http, :request-method :post}, :headers nil, :app #ob}
I’m making the request like so:
(require '[peridot.core :refer [content-type request session])
(-> session
(request "/api/schools"
:params {:name name
:timezone (or timezone "America/New_York")}
:request-method :post))
this is my reitit handler:
["/schools" {:swagger {:tags ["schools"]}}
["" {:post {:description "create a school"
:parameters {:body {:timezone string?
:name string?}}
:handler create-school-handler}}]
...]
FYI I have these three middleware ([reitit.ring.coercion :as rrc]):
rrc/coerce-exceptions-middleware
rrc/coerce-request-middleware
rrc/coerce-response-middleware
I don’t see the error when I remove the middleware
@ps Based on \"pred\":\"clojure.core/map?\",\"val\":null
-- it's saying that it got null
via JSON but expected a (non-nil) hash map, if I'm reading it correctly. Maybe ask in #reitit?
@seancorfield why would it get null via json? When I remove the coerce middleware, the params are right there in the handler
No idea. That's why I suggested asking in #reitit (which I do not use).
(since it seems to be related to the reitit middleware, more than Spec)