This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-12
Channels
- # adventofcode (1)
- # announcements (6)
- # babashka (28)
- # beginners (36)
- # calva (8)
- # clj-commons (4)
- # clojure (35)
- # clojure-austin (5)
- # clojure-europe (7)
- # clojurescript (14)
- # clr (1)
- # datalevin (1)
- # fulcro (7)
- # funcool (1)
- # graphql (4)
- # helix (3)
- # hyperfiddle (4)
- # joyride (15)
- # malli (1)
- # missionary (16)
- # practicalli (1)
- # releases (1)
- # reveal (2)
- # tools-deps (14)
- # vim (9)
I am trying to do the equivalent of this curl using the new babashka/http-client:
curl --location --request PATCH '' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer blablabla \
--data-raw '{
"name": "name1",
"template": false,
"certificate": "656e239e-2442-4261-ae29-9e2442f261b8",
"enabled": true,
"identities": ["3fa941ee-9491-4373-a941-ee9491b3713e"]
}'
However when I try to do this with:
(http/patch ""
{:headers
{"authorization" "Bearer blablabla"}
:body "{\"name\": \"name1\",\"template\": false,\"certificate\": \"656e239e-2442-4261-ae29-9e2442f261b8\",\"enabled\": true,\"identities\": [\"3fa941ee-9491-4373-a941-ee9491b3713e\"]}"})
I get an HTTP 415 Unsupported Media Type
. I think it’s related to the JSON I’m trying to pass. But I can’t seem to get it into the “raw” sort of format I need similar to the curl. Anyone have any clues?@U0250GGJGAE I think you might need to set the content type explicitly to application/x-www-form-urlencoded
The API wont handle urlencoded posts / patches, it need application/json - but let me explicitly set that and see
sorry, I missed the content type in your curl request, curl by default sends the content type I wrote earlier.
Ok - yeah, I think that’s gotten me past this hurdle. Checking further, but I think that did it. Thank you sir.
Confirmed fully. All good now 👍.
I was wondering, I am fooling around with scittle inside a ring, sibiro, hiccup made website - which works great btw. Would it be somehow possible to trigger a Clojure function in the surrounding code from inside scittle code? I copied the default scittle examples and they work perfectly. https://gist.github.com/LouDnl/82b4020555afaf322a3381525451052d
do you mean in the sense of sharing code between server and browser or do you mean in the sense of browser making a web request (like in example)
In any sense for that matter. Doing requests server side back and forth to transit requests would be the simplest I guess? I am just messing around with scittle (which is really cool btw), using it inline in a Clojure project that uses hiccup. See snippet above. Would there - without using server side requests - be any way to call a Clojure function that is outside the [:script] tag? Probably not I'm guessing?
For this test I want to save myself the hassle of adding Clojurescript to the project and Scittle is superb for that
you could move the code you want to share into a cljs file, and use script
src=/fiile.cljs
with "application/x-scittle" type and it gets loaded
Thats one thing then, but from that cljs file it would be possible to trigger a Clojure function without a request?
You'll need a request at some point if the browser should trigger something on the server. Probably ajax + ring handlers is what you want
Good point indeed. For other projects I use jQuery to reload a hiccup div into itself and it automatically reloads the clojure code :melting_face:
First time venturing into Scittle as it seems much easier to start with then adding cljs to a clj project
yea I had the same experience it immediately works and Clojurescript is sort of heavy to use
Indeed, it had me add more dependencies, needs to be compiled to use. Very confusing if you have not done that before but do know your way around clj

@U02CX2V8PJN There's also a #C034FQN490E channel :-)
Can you move the big chunk of code to a Github gist or attachment or so? It's good etiquette not to flood the channel with big chunks of text