an idiomatic Clojure HTTP client wrapping the Apache client
Questions tagged [clj-http]
34 questions
7
votes
1 answer
How to fix ERR_INVALID_CHUNKED_ENCODING error?
I have a Clojure application that acts as a proxy service. The goal is to proxy requests to http://127.0.0.1:3000 (Grafana service) through the path "/grafana", so that if I access http://127.0.0.1/grafana through the browser, it should proxy my…

Edmond
- 615
- 1
- 5
- 15
6
votes
1 answer
clj-http not returning JSON
I am trying to read JSON from a REST resource using clj-http version 2.2.0 but whatever I do I get the result as a string.
While debugging, I stripped down what I'm doing to this request to a static JSON document on my webserver on…

Matthias Wimmer
- 3,789
- 2
- 22
- 41
4
votes
2 answers
Proper way to ensure clj-http's connection manager is closed after all requests are done
I have a code that is a combination of clj-http, core.async facilities and an atom. It creates some threads to fetch and parse a bunch of pages:
(defn fetch-page
([url] (fetch-page url nil))
([url conn-manager]
(-> (http.client/get url…

Matheus Moreira
- 2,338
- 4
- 24
- 31
4
votes
1 answer
How to setting cookie in clj-http?
For example, I need to parse data from my imdb.com account. So, the task is get currently logged page. I taken the "id" cookie from browser. And make GET request, but it doesn't works.
(ns imdb.core
(:require [clj-http.client :as client])
(def…

Tim
- 96
- 5
3
votes
2 answers
Post Request in Clojure with clj-http - body not accepted?
With my post request the API documentation for the CRM I wish to post too requires that I post a JSON file.
The JSON file is a multi-level file which is seen in clojure as a persistent array map.
My code to post is:
(def contacts (http/post…

Vinn
- 1,030
- 5
- 13
3
votes
1 answer
Passing all requests to /api/v1/** to the old api server
For the 2nd iteration of our API we are performing a complete re-write.
To make the transition smooth I would like to setup our new server with an API endpoint /api/v1/** such that it will become a mirror of the old server.
Is there any built in…

Eyal
- 758
- 6
- 23
3
votes
1 answer
Pass multiple query parameter values with clj-http
I need to make a web request to an external service (Twilio), with multiple values specified for the same parameter, e.g.
GET /some-url?status=1&status=2&status=3
How do I tell clj-http to encode the request like this?

Petrus Theron
- 27,855
- 36
- 153
- 287
2
votes
2 answers
Clj-http exception: ExceptionInfo clj-http: status 415 clj-http.client/wrap-exceptions/fn--1863 (client.clj:196)
I am using clj-http for API calls but i am getting very generic error message.
ExceptionInfo clj-http: status 415 clj-http.client/wrap-exceptions/fn--1863 (client.clj:196)
How can i see the full response from API?

benbro00002
- 151
- 4
2
votes
1 answer
422 Unprocessable Entity response when POSTing file upload in Clojure
I am trying to emulate this curl request
curl "https://{subdomain}.zendesk.com/api/v2/uploads.json?filename=myfile.dat&token={optional_token}" \
-v -u {email_address}:{password} \
-H "Content-Type: application/binary" \
--data-binary @file.dat…

sansovich
- 21
- 3
2
votes
0 answers
clj-http get request: SSLException
I'm having troubles accessing a https url via a clj-http get-request.
The same URL works perfectly with a simple curl request. In clojure, I just get it working when using the :insecure? true flag.
Here's the error I get otherwise:
SSLException…

Anton Harald
- 5,772
- 4
- 27
- 61
2
votes
2 answers
clj-http/get url {:as :json} doesn't work in script but in REPL
I'm experimenting with Clojure and Leiningen.
I was successful in executing to following line in the REPL:
(print (:body (client/get "https://coinbase.com/api/v1/prices/spot_rate?currency=CAD" {:as :json}))
I created a project with lein new http.…

Steffen Roller
- 3,464
- 25
- 43
2
votes
2 answers
How to wrap oAuth headers in clj-http?
I'm trying to post a twitter status update with clojure... but this probably really is a question about oAuth headers, and using it through the wonderful clj-http library.
I've used clj-http before for basic-auth and other type of headers and it was…

LocustHorde
- 6,361
- 16
- 65
- 94
1
vote
0 answers
403 when testing local post request using clj-http
I have a route defined as:
(POST "/login" [req] req)
in my httpkit server. I wanted to test this route so I tried to use:
(client/post "http://localhost:3000/login" {})
using clj-http.client, but I just get error 403 (forbidden) when I attempt to…

Jack Gee
- 136
- 6
1
vote
2 answers
Problems with Google Api query in Clojure
When I am executing the following query
(require '[clj-http.client :as http])
(http/post "https://www.googleapis.com/oauth2/v1/userinfo"
{:query-params {:access_token "token"}})
SunCertPathBuilderException unable to find valid…

JONATHAN
- 11
- 1
1
vote
1 answer
How to use `clj-http` connection pool from a ring web application?
I am using a clojure web application as a proxy web server.
All of my requests are coming into this clojure ring web application then I use clj-http to send the request on to the final destination.
So I have this working as a naive solution so far…

Nicholas DiPiazza
- 10,029
- 11
- 83
- 152