【问题标题】:How to pass data with GET request?如何使用 GET 请求传递数据?
【发布时间】:2019-09-07 16:15:34
【问题描述】:

我想通过 GET 请求传递表单数据。

我在这个 curl 上取得了成功: curl http://sample.com -d 'action=login_request&user_name=balvan'

但我需要从-d 传递同样的东西。使用此函数调用:

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

如何在请求正文中添加那些“-d”参数?

我在 ns 声明中有 [org.httpkit.client :as http-client],在项目的依赖项中有 [cheshire "5.8.1"]

【问题讨论】:

标签: clojure http-kit cheshire


【解决方案1】:

发出man curl 告诉我们 -d 标志将发送带有数据的发布请求。

-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...

你想做的是:

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

【讨论】:

    猜你喜欢
    • 2016-04-17
    • 2019-06-07
    • 2020-05-25
    • 1970-01-01
    • 1970-01-01
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    • 2018-02-19
    相关资源
    最近更新 更多