<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged rest</title>
<link>https://ask.clojure.org/index.php/tag/rest</link>
<description></description>
<item>
<title>REST API response body is not a string?</title>
<link>https://ask.clojure.org/index.php/10217/rest-api-response-body-is-not-a-string</link>
<description>&lt;p&gt;It's been a while since I've written Clojure, so I am rusty.&lt;/p&gt;
&lt;p&gt;Basically, I'm trying to write code which does an HTTP GET on a REST API and converts that JSON array of objects into clojure data (list of Maps?). The JSON data looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[
    {
        &quot;id&quot;: 1,
        &quot;category&quot;: &quot;technical&quot;,
        &quot;asin&quot;: &quot;0131103628&quot;,
        &quot;title&quot;: &quot;C Programming Language, 2nd Edition&quot;,
        &quot;publication_date&quot;: &quot;1988-04-01T00:00:00Z&quot;,
        &quot;review&quot;: &quot;The C book.&quot;,
        &quot;created_at&quot;: &quot;2020-03-06T20:48:00Z&quot;
    },
    {
        &quot;id&quot;: 2,
        &quot;category&quot;: &quot;technical&quot;,
        &quot;asin&quot;: &quot;0387966080&quot;,
        &quot;title&quot;: &quot;The Science of Fractal Images&quot;,
        &quot;publication_date&quot;: &quot;1988-07-19T00:00:00Z&quot;,
        &quot;review&quot;: &quot;The book on fractal algorithms.  Sadly, no longer in print.  I had to search high and low for a used copied.&quot;,
        &quot;created_at&quot;: &quot;2020-03-06T20:48:00Z&quot;
    },
    // etc..
]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I'm using &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/http-kit/http-kit&quot;&gt;http-kit&lt;/a&gt; (I've also tried &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/dakrone/clj-http&quot;&gt;clj-http&lt;/a&gt;) to call the REST API and return the body. Later, I try converting the body to Clojure data. I've tried using both &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/data.json&quot;&gt;org.clojure/data.json&lt;/a&gt; and &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/dakrone/cheshire&quot;&gt;cheshire&lt;/a&gt;.  However, I don't belive the data is being converted correctly.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn get-books-body
  []
  (:body @(client/get books-url api-options)))

(defn get-books
  []
  (parse-string get-books-body true))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When I try to display the type of the body, it shows up as an address instead of a string:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clojure-json-test.core=&amp;gt; (type get-books-body)
clojure_json_test.core$get_books_body
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And I cannot look at the first record, after converting from JSON:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clojure-json-test.core=&amp;gt; (first get-books)
Execution error (IllegalArgumentException) at clojure-json-test.core/eval3169 (form-      init15378865171954877190.clj:1).
Don't know how to create ISeq from: clojure_json_test.core$get_books
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any idea what I am doing wrong?&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10217/rest-api-response-body-is-not-a-string</guid>
<pubDate>Sat, 20 Feb 2021 08:42:46 +0000</pubDate>
</item>
</channel>
</rss>