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 "https://api.close.com/api/v1/data/search"
{:basic-auth [api ""]
:body closeFilter
}))
CloseFilter represents the mutli-level JSON I wish to post.
However, I get the following error:
class clojure.lang.PersistentArrayMap cannot be cast to class [B (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; [B is in module java.base of loader 'bootstrap')
What mistake am I making here?
Update
I am recreating a program I have in Javascript. Posting the same file works perfectly.
Update 2 - MRE
I am still struggling with this so here is an example of my code.
My code starts off by requiring the packages I need:
(ns schedule-emails.core
(:require [clj-http.client :as http]
[clojure.data.json :as json]
[cheshire.core :refer :all]))
Then, I parse a local JSON file from my file system into the app. The JSON. This returns a map of maps with embedded vectors.
(def closeFilter
(json/read-str
(slurp "URL TO LOCAL FILE")))
Finally, I want to post this information from the local file to the software:
def contacts (http/post "API URL HERE"
{:accept :json
:as :json
:content-type :json
:basic-auth [api ""]
:body closeFilter}))
However, I get the following error:
class clojure.lang.PersistentArrayMap cannot be cast to class [B (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; [B is in module java.base of loader 'bootstrap')
I also tried the suggested solution below but i'm getting the same issue.