【发布时间】:2022-06-12 18:19:34
【问题描述】:
通过我的发布请求,我希望发布的 CRM 的 API 文档也要求我发布 JSON 文件。
JSON 文件是一个多级文件,在 clojure 中被视为一个持久数组映射。
我要发布的代码是:
(def contacts (http/post "https://api.close.com/api/v1/data/search"
{:basic-auth [api ""]
:body closeFilter
}))
CloseFilter 表示我希望发布的多级 JSON。
但是,我收到以下错误:
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')
我在这里犯了什么错误?
更新
我正在用 Javascript 重新创建一个程序。发布相同的文件效果很好。
更新 2 - MRE
我仍在为此苦苦挣扎,所以这是我的代码示例。
我的代码首先需要我需要的包:
(ns schedule-emails.core
(:require [clj-http.client :as http]
[clojure.data.json :as json]
[cheshire.core :refer :all]))
然后,我将文件系统中的本地 JSON 文件解析到应用程序中。 JSON。这会返回一个带有嵌入向量的地图。
(def closeFilter
(json/read-str
(slurp "URL TO LOCAL FILE")))
最后,我想将本地文件中的这些信息发布到软件中:
def contacts (http/post "API URL HERE"
{:accept :json
:as :json
:content-type :json
:basic-auth [api ""]
:body closeFilter}))
但是,我收到以下错误:
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')
我也尝试了下面建议的解决方案,但我遇到了同样的问题。
【问题讨论】: