@borkdude I don't know if you already discovered the limitations of the local-echo-controller? it's not really suitable for lisp, quoting will not work as you would expect
Fixed in babashka/local-echo, issue/PR here: https://github.com/wavesoft/local-echo/issues/30
@plexus yes, I’m working on a fork of the local-echo-controller for that. We basically control incomplete input ourselves instead of needing that part of the plugin to do it for us
that's good, local-echo-controller does too much, it should really do only exactly as much as a unix line discipline driver
@plexus in general a text area with some Clojure syntax plugin may be more ergonomic for web (we already have sci.web playground) but this is a fun idea of yours! Further discussion in #sci
hello! I'm trying to talk to an api with babashka curl. Can anyone tell me what is malformed about this request?
(curl/put "<https://gitlab.logicgate.com/api/v4/projects/97/pipeline_schedules/111>"
{:headers {"PRIVATE-TOKEN" "itIsSecret"
"Content-Type" "application/json"}
:form-params {"description" "I am renaming this pipeline schedule"}})
I got an unwrapped curl command to succeed with this, so I guess the above is not equivalent to the command I used
@mathpunk if you invoke curl with :debug true
it will also include the command in the ex-data
:
"curl" "--silent" "--show-error" "--location" "--dump-header" "/var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/babashka.curl5567161590767606780.headers" "--request" "PUT" "-H" "PRIVATE-TOKEN: itIsSecret" "-H" "Content-Type: application/json" "--form" "description=I am renaming this pipeline schedule" "<https://gitlab.logicgate.com/api/v4/projects/97/pipeline_schedules/111>"
Maybe that will help you debughmm, same result I think: status 400. The output:
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: babashka.curl: status 400
Location: /Users/tomhenderson/lg/tools/./jobs.clj:125:1
----- Context ------------------------------------------------------------------
121: :body
122: (json/parse-string))
123:
124:
125: (curl/put "<https://gitlab.logicgate.com/api/v4/projects/97/pipeline_schedules/111/>"
^--- babashka.curl: status 400
126: {:headers {"PRIVATE-TOKEN" token
127: "Content-Type" "application/json"}
128: :form-params {"description" "I am renaming this pipeline schedule"}
129: :debug true})
----- Stack trace --------------------------------------------------------------
babashka.curl/put - <built-in>
user - /Users/tomhenderson/lg/tools/./jobs.clj:125:1
I thought maybe my error was to put both :headers
and :form-params
in the same map but I guess not
@mathpunk Could be a bug in babashka/curl. Can you try if this works with e.g. clj-http or httpkit? Next release will have the latter
@mathpunk Yes, the output is the same but there is extra data in the exception, which you can get with (ex-data *e)
, e.g. (:command (ex-data *e))
alas, first time writing a babashka script, I seem to not quite understand how to require clj-http :thinking_face: or print the ex-data
(do
(curl/put "<https://gitlab.logicgate.com/api/v4/projects/97/pipeline_schedules/111/>"
{:headers {"PRIVATE-TOKEN" token
"Content-Type" "application/json"}
:form-params {"description" "I am renaming this pipeline schedule"}
:debug true})
(pprint (:command (ex-data *e))))
but the output looks the same to me
@mathpunk I think I understand the problem. You state: content-type application/json, but that's not what you're sending
ohhhh
i thought that was to tell the server what i wanted back
no, that's accept
and there it is! thank you!
I noticed clj-http automatically makes the content-type "content-type: application/x-www-form-urlencoded"
when you use form-params, maybe babashka/curl should too
but since the user explicitly provides a content-type here, maybe not
np :)