question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a support for client POST with pure json data?

See original GitHub issue

In the same way as this clj-http does with this snippet

(clj-http.client/post { :body "{\"json\": \"input\"}" })

Seems like neither query-params nor form-params can be used for that.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
allen-servediocommented, Sep 14, 2017

For anyone else that runs across this issue, you have to add a Content-Type header for this to work with most servers…

(http/post "url" {:body (json-str {:key "value", :key2 ["arr"]})
                  :headers {"Content-Type" "application/json"}})
2reactions
owapcommented, Aug 21, 2020

I solved this problem earlier today by leveraging https://github.com/clojure/data.json to encode the body

(ns your-namespace.core
  (:require
    [clj-http.client :as http]
    [clojure.data.json :as json]))

(def github-token "redacted")

(defn make-request [query]
  (->
   (http/post "https://api.github.com/graphql"
              {:headers {:Authorization (str "bearer " github-token)}
               :body (json/write-str {:query query})
               :accept :json
               :throw-entire-message? true})
   :body
   (json/read-str :key-fn keyword)))

Hope this helps somebody 😀

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Generate/Send JSON Data at the Client Side
How to Generate/Send JSON Data at the Client Side ?
Read more >
Sending and Receiving JSON using HttpClient with System ...
In this post, I introduce System.Net.Http.Json for sending and recieveing JSON content to external services using HttpClient in .NET.
Read more >
JSON POST request with Postman - YouTube
In this video, I will show you how to create a simple POST request with Postman and send JSON. The endpoint used here...
Read more >
How do I send a POST request using JavaScript? - ReqBin
This new API provides a more powerful and flexible set of features than the XMLHttpRequest object. The Fetch API makes extensive use of...
Read more >
Replace RESTful APIs with JSON-Pure - Michael S. Mikowski
That means that at least on the browser client, we will be using JSON.parse() and JSON.stringify() to parse and send the data respectively....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found