# Genie: Basic API backend question

**URL:** <https://discourse.julialang.org/t/genie-basic-api-backend-question/104523>\
**Category:** General Usage\
**Tags:** question, error, genie\
**Created:** [October 3, 2023, 4:07am UTC](https://discourse.julialang.org/t/genie-basic-api-backend-question/104523 "2023-10-03T04:07:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ethan\_Leonard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_leonard/32/44018_2.png) [@Ethan\_Leonard](https://discourse.julialang.org/u/Ethan_Leonard)\
**Post date:** [October 3, 2023, 4:07am UTC](https://discourse.julialang.org/t/genie-basic-api-backend-question/104523/1 "2023-10-03T04:07:42Z")

</div>

I keep getting this error :

> ######################### ERROR STACKTRACE #########################  
> Expected end of input  
> Line: 0  
> Around: …11092×16 DataFrame Row…

But when I run the code (excluding the routes) in a separate terminal, it runs just fine, returning a DataFrame of securities symbols with some information about them.

What am I doing wrong? (_Note that the api key published here is a publishable key that only has access to free data._)

```julia
using Genie, Genie.Renderer.Json, Genie.Requests
using HTTP, JSON
using DataFrames

route("/tickers", method = POST) do
  message = jsonpayload()
# (:echo => (message["message"] * " ") ^ message["repeat"]) |> json
    syms = HTTP.request("GET","https://acre.iex.cloud/v1/data/CORE/REF_DATA?token=pk_79891f5cbcce4099ae063588956f937a")
    schema_req = HTTP.request("GET","https://acre.iex.cloud/v1/data/CORE/REF_DATA?schema=true&token=pk_79891f5cbcce4099ae063588956f937a")
    sbs = syms.body |> String |> JSON.parse
    smat = sbs .|> values .|> collect |> (x->reduce(hcat,x)) |> (x->permutedims(DataFrame(x,:auto)))
    schema = schema_req.body |> String |> JSON.parse |> first |> keys |> collect
    rename!(smat,Symbol.(schema))
end

route("/send") do
  response = HTTP.request("POST", "http://localhost:8000/tickers", [("Content-Type", "application/json")], """{"exchanges":"XNYS", "type":"cs"}""")
  response.body |> String |> JSON.parse
end

up(async = false)

```

Ultimately, I’d like the ‘/tickers’ route to be an API backend and the `/send` route to exist in a desktop application (not necessarily as a webpage), so answers without relying heavily on formatting the `/send` route are very welcome.

Thanks!

* * *

UPDATE:  
I found out that changing the line

`response.body |> String |> JSON.parse`

to

`response.body |> String |> Genie.Renderer.Json.json`

gets rid of the error. I’m guessing it’s because Genie requires its own `json` method to pass json objects, not `JSON.parse`. (Also, I can’t just use ‘|\> `json`’ like in the Genie example, because the keyword `json` is exported by two modules that I imported, so I have to specify that this is the Genie one.)

**Now it looks like this, and I’d like to know of a way to receive a dataframe as a response and not this monstrosity. Any ideas?**

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/f/af2b261cbe13c859436977043e0b16d4dbcee769.png)

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [October 3, 2023, 4:02pm UTC](https://discourse.julialang.org/t/genie-basic-api-backend-question/104523/2 "2023-10-03T16:02:15Z")

</div>

Could you show the entire error?

---

<div class="post-metadata">

**Author:** ![Ethan\_Leonard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_leonard/32/44018_2.png) [@Ethan\_Leonard](https://discourse.julialang.org/u/Ethan_Leonard)\
**Post date:** [October 3, 2023, 6:34pm UTC](https://discourse.julialang.org/t/genie-basic-api-backend-question/104523/3 "2023-10-03T18:34:46Z")

</div>

I progressed a bit past this, but ran into a new problem. Would the old error still help, or do you think this is approachable as is now?
