Skip to content

HTTP client should be configured to use {:content-type :json} by default #265

Description

@qleguennec

When executing the following snippet:

(ns zenika-elastitsch.core
  (:require
   [clojurewerkz.elastisch.rest :as esr]
   [clojurewerkz.elastisch.rest.index :as esi]
   [clojurewerkz.elastisch.rest.document :as esd]
   [clojure.spec.alpha :as spec]
   [clojure.spec.gen.alpha :as gen]))

(spec/def ::first-name string?) 
(spec/def ::last-name string?)
(spec/def ::age (spec/and int? #(> % 0)))
(spec/def ::email string?)
(spec/def ::skill #{:react :node :elasticsearch :clojure})
(spec/def ::skills (spec/coll-of ::skill :into #{}))

(spec/def ::person (spec/keys :req [::first-name ::last-name ::age ::email]
                              :opt [::skills]))

(def person-example {::first-name "Quentin"
                     ::last-name "Le Guennec"
                     ::age 24
                     ::email "quentin.leguennec@zenika.com"
                     ::skills '(:react :clojure :elasticsearch)})
(spec/explain ::person 
              person-example)

(def conn (esr/connect "http://localhost:9200"))
(def mappings {"person" {:properties {:first-name {:type "string"}
                                      :last-name {:type "string"}
                                      :age {:type "integer"}
                                      :email {:type "string"}
                                      :skills {:type "array"}}}})

(esi/create conn "zenika" :mappings mappings)
(esd/create conn "zenika" "person" person-example)

I'm getting this error:

Unhandled clojure.lang.ExceptionInfo
   clj-http: status 406
   {:status 406,
    :headers
    {"content-type" "application/json; charset=UTF-8",
     "content-length" "112"},
    :body
    "{\"error\":\"Content-Type header [text/plain; charset=UTF-8] is not supported\",\"status\":406}",
    :request-time 36,
    :trace-redirects ["http://localhost:9200/zenika/person"],
    :orig-content-encoding "gzip"}

How to solve this? Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions