# Facing issue with genie for a sample test function

**URL:** <https://discourse.julialang.org/t/facing-issue-with-genie-for-a-sample-test-function/118992>\
**Category:** New to Julia\
**Tags:** question, genie\
**Created:** [September 3, 2024, 12:58pm UTC](https://discourse.julialang.org/t/facing-issue-with-genie-for-a-sample-test-function/118992 "2024-09-03T12:58:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shiva\_raj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shiva_raj/32/50626_2.png) [@Shiva\_raj](https://discourse.julialang.org/u/Shiva_raj)\
**Post date:** [September 3, 2024, 12:58pm UTC](https://discourse.julialang.org/t/facing-issue-with-genie-for-a-sample-test-function/118992/1 "2024-09-03T12:58:47Z")

</div>

Hi Team,  
when I run the below code I get error , please help me to fix as I am testing a new project with Genie.

```julia
module App
using Genie
using Genie.Router
using Genie.Renderer
using Genie.Requests
using Genie.Renderer.Json
#using Genie.Requests.Params

include("add.jl")
using Genie.Renderer.Json
route("/add", method = POST) do
     data = jsonpayload()
     a = parse(Int, data["a"])
     b = parse(Int, data["b"])
     sum = add(a, b)
    return JSON(:result => sum)
end

end

```

Add function code

```julia
function add(a::Int, b::Int)
    return a + b
end

```

when I send a below curl request I get error

```julia
curl -X POST 'http://localhost:8000/add/' -H 'Content-Type: application/json' -d '{"a": "10","b": "28"}'
 
{"error":"500 Internal Error - UndefVarError: `JSON` not defined\nStacktrace:\n [1] (::Main.App.var\"#1#2\")()\n    
@ Main.App /home/shiva/gitcode/Maths-project/module/Genie/genie.jl:16\n [2] run_route(r::Genie.Router.Route)\n    
@ Genie.Router ~/.julia/packages/Genie/3gPCR/src/Router.jl:535\n [3] route_request(req::HTTP.Messages.Request, res::HTTP.Messages.Response)\n   
 @ Genie.Router ~/.julia/packages/Genie/3gPCR/src/Router.jl:171\n [4] handle_request(req::HTTP.Messages.Request, res::HTTP.Messages.Response)\n    
 @ Genie.Server ~/.julia/packages/Genie/3gPCR/src/Server.jl:278\n [5] (::Genie.Server.var\"#29#30\"{HTTP.Messages.Request, HTTP.Messages.Response})()\n   
 @ Genie.Server /home/shiva/julia/julia-1.10.4/share/julia/stdlib/v1.10/Distributed/src/macros.jl:123\n [6] #invokelatest#2\n   
 @ ./essentials.jl:892 [inlined]\n [7] invokelatest\n @ ./essentials.jl:889 [inlined]\n [8] #153\n  
 @ /home/shiva/julia/julia-1.10.4/share/julia/stdlib/v1.10/Distributed/src/remotecal

```

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [September 3, 2024, 5:40pm UTC](https://discourse.julialang.org/t/facing-issue-with-genie-for-a-sample-test-function/118992/2 "2024-09-03T17:40:10Z")

</div>

I’m not familiar with Genie’s exports, but

> [@Shiva\_raj](#):
>
> `using Genie.Renderer.Json`

And

> [@Shiva\_raj](#):
>
> `return JSON(:result => sum)`

Have different case (Json vs JSON). Maybe try `return Json(:result, => sum)`?

---

<div class="post-metadata">

**Author:** ![Shiva\_raj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shiva_raj/32/50626_2.png) [@Shiva\_raj](https://discourse.julialang.org/u/Shiva_raj)\
**Post date:** [September 7, 2024, 3:52pm UTC](https://discourse.julialang.org/t/facing-issue-with-genie-for-a-sample-test-function/118992/3 "2024-09-07T15:52:57Z")

</div>

Thanks for the help!  
that worked…  
@kevbonham
