I want to pass form data with GET request.

I have success with this curl: curl http://sample.com -d 'action=login_request&user_name=balvan'

but I need to pass that same stuff from -d. with this function call:

(http-client/request
                             {:url             base-url
                              :method          :get
                              :deadlock-guard? false
                              :insecure?       true})

How to add those "-d" parameters within the request body?

I am have [org.httpkit.client :as http-client] in ns declaration and [cheshire "5.8.1"] in project's dependencies.

1 Answers

1
lightlight On Best Solutions

Issuing man curl tells us that the -d flag will send a post request with data.

-d, --data <data>
    (HTTP)  Sends  the  specified data in a POST request to the HTTP
    cause curl to pass the data to the server using the content-type
    -d, --data is the same as --data-ascii. --data-raw is almost the
    ter...

What you want to do is:

(http-client/request
  {:url              base-url
   :method           :post
   :form-params      {"action" "login_request"
                      "user_name" "balvan"}
   :deadlock-guard?  false
   :insecure?        true})