Parameter Mismatch: :name parameter data not found. error

I am sending an map to uppdade my database with the following code in luminus:

home.clj:

(defn par [req]
 (db/addb (:latest (:params req))))

(defn home-routes []
  [ "" 
   ;; {:middleware [middleware/wrap-csrf
   ;;               middleware/wrap-formats]}
   ["/" {:get home-page}]
   ["/about" {:get about-page}]
   ["/test" par]])

queries.clj:

--:name addb :! :n
--:doc adds another booking
INSERT INTO rent
(name,org,parea,barea,tarea,hyra,omk,tid,start,stop,notes,kost,kost2)
VALUES (:name, :org, :parea, :barea, :tarea, :hyra, :omk, :tid, :start, :stop, :notes, :kost, :kost2)

the dict comes from a form on a html page and looks as follows:

{:area2 "187", :tid 8.0, :area1 "166", :block "stora", :barea 187.0, :parea 167.0, :name "noname", :start "1", :hkv 116.32653061224491, :org "999", :stop "2", :kost2 2196.2449, :hyra 61000.0, :tarea 980.0, :notes "notes here", :tk 114000.0, :omk 53000.0, :test 167.0, :kost 274.5306, :pb 354.0}

As seen, the name parameter is there but there is still an error that it is not found. any ideas?

Is the problem (:latest … )? I can’t see the :latest key in the map.

the map that you see is calles latest, and it is in params and params is in req. so something like this:

req: {:params {:latest …}}

If I give a test map like:

(db/addb {:name “test” …})

…}

then it will not complain about the missing name parameter. So something is happenning on the way to the execution of addb. maybe another paranthesis is added somewhere?

and there is another strange error:
if I submitt this map to addb

(db/addb {:name "jonas" :org "sdf" :parea 23 :barea 34 :tarea 65 :hyra 3232 :omk 4343 :tid 23 :start 43 :stop 56 :notes "notes" :kost 65 :kost2 34})

then I get the following error:

ERROR rental.middleware - contains? not supported on type: java.lang.Integer 
java.lang.IllegalArgumentException: contains? not supported on type: java.lang.Integer

And that I don’t understand either.

ok, so now it works using all the input fields as input. Interestingly, the error

ERROR rental.middleware - contains? not supported on type: java.lang.Integer 
java.lang.IllegalArgumentException: contains? not supported on type: java.lang.Integer

only arrives if I call addb with two paranthesis like this:

(defn par [{:keys [params]}] 
  (db/addb params))

but if I call with one instead, the error disappear:

(defn par [{:keys [params]}] 
  (db/addb params)
..)

so paranthesis has an extrem importance here…
The only thing left now is to get rid of all input fields…

To the best of my knowledge, those two statements are functionally identically. The positioning of your closing parenthesis in the second example should have no bearing on the execution.

Now, regarding your main problem, what does your ring handler initialization code look like? You want to access parameters, but you can only do that if you use the correct middleware, for example

   [reitit.ring.middleware.parameters
    :refer (parameters-middleware)]

and include that either in your route data, or in the :data:middleware map for your ring handler. It would be interesting to see what else you have included there. Understanding how middleware is applied is one of the most important aspects of understanding reitit, and it isn’t necessarily intuitive.