【问题标题】:Scala - Send Multiple Headers with scalaj.http.HttpScala - 使用 scalaj.http.Http 发送多个标头
【发布时间】:2015-04-25 16:47:50
【问题描述】:

我正在向下面列出的库发出发布请求。好像我的最后一个标题被切断了。我尝试了以下两种方法,但似乎都不起作用。

import scalaj.http._
import scalaj.http.Http


var result = Http("https://example.com" + Key + "/rowset")
  .postData(jsonOutput)
  .headers(Seq("Authorization" -> ("Bearer " + accessToken)))
  .headers(Seq("content-Type" -> "application/json"))


var result = Http("https://example.com" + Key + "/rowset")
  .postData(jsonOutput)
  .headers(Seq("Authorization" -> ("Bearer " + accessToken), "content-Type" -> "application/json"))

【问题讨论】:

  • 由于某种原因,它的工作方式如下: var result = Http("example.com/v1/requestToken") .postForm .param("clientSecret", "XXXX") .param("clientId" , "YYYY")

标签: java scala http post web


【解决方案1】:

只是为了检查;你正在对结果变量做些什么?它仍然只是一个请求,并且会一直保持下去,直到您调用 result.asString,它将执行请求并返回响应(如果是 asString,则为 HttpResponse[String])。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-16
    • 1970-01-01
    • 2018-03-17
    • 2014-09-20
    • 1970-01-01
    • 2017-09-05
    • 2023-04-09
    • 2012-01-09
    相关资源
    最近更新 更多