This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-29
Channels
- # aws (6)
- # beginners (33)
- # bitcoin (2)
- # boot (22)
- # carry (2)
- # cider (5)
- # clara (21)
- # cljs-dev (115)
- # cljsrn (40)
- # clojure (161)
- # clojure-dev (73)
- # clojure-italy (38)
- # clojure-russia (88)
- # clojure-spec (123)
- # clojure-uk (58)
- # clojurescript (88)
- # core-async (26)
- # cursive (5)
- # datascript (18)
- # datomic (26)
- # hoplon (50)
- # java (2)
- # jobs (1)
- # leiningen (10)
- # lumo (1)
- # off-topic (18)
- # om (9)
- # onyx (26)
- # parinfer (13)
- # pedestal (41)
- # quil (1)
- # re-frame (27)
- # reagent (21)
- # ring-swagger (11)
- # slack-help (3)
- # spacemacs (8)
- # specter (5)
- # sql (42)
- # timbre (1)
- # uncomplicate (7)
- # untangled (3)
- # videos (1)
- # yada (26)
Hiii, why do I get a 204 No Content
when I POST to try to create the phone number resource?
(defn post-phone [ctx]
(phones/write-number-reported (:number (:parameters ctx)) (:country (:parameters ctx))))
(defn get-phone [ctx]
(defn post-phone [ctx]
(phones/read-number-reported (:number (:parameters ctx)))))
(defn server-routes []
[""
[
["/about" (yada/as-resource "Hello World")]
["/phone" :number (yada/resource
{:methods
{:get
{:parameters {:path {:number String}}
:produces "application/json"
:response get-phone}
:post {:parameters {:path {:number String}
:body {:country String}}
:consumes "application/json"
:produces "application/json"
:response post-phone}}})]]])
curl -X POST -H 'cache-control: no-cache' -H 'content-type: application/json' -d '{"country":"us"}' -i
What is post-phone
returning?
yeah 🙂
are your routes correct there?
I would have expected something more like [["/phone" :number] (yada/resource ...)]
Ahh. Thanks for the link! OK, I adjusted to that format, still getting a 204.
(defn server-routes []
[""
[
["/about" (yada/as-resource "Hello World")]
["/phone"
[
[["/" :number] (yada/resource
{:methods
{:get
{:parameters {:path {:number String}}
:produces "application/json"
:response get-phone}
:post {:parameters {:path {:number String}
:body {:country String}}
:consumes "application/json"
:produces "application/json"
:response post-phone}}})]]]]])
I know
When you return {}
Yada doesn't know if that is a resource, or a map
you should instead get the response out of the context, add the {} to that, and return it
(assoc-in ctx [:response :body] {})
See yada.methods:250
for what's happening
actually line 305
I found out my problem, not sure how to fix it though. Everything resolves fine if I don't have an encoded URL, like
... however, if there's an encoded char in the URL, that's when I get the 204
, like
relevant resource:
(defn server-routes []
[""
[["/about" (yada/as-resource "Hello World")]
["/phone"
[[["/" :number] (yada/resource
{:parameters {:path {:number String}}
:produces ["application/json"]
:methods
{:get {:response get-phone}
:post {:parameters {:body {:country String}}
:consumes "application/json"
:response post-phone}}})]]]]])