Scalaj 数据 Urlencode

Scalaj Data Urlencode

当我使用 curl 执行 POST 请求时,它看起来是这样的:

curl -k -X POST \    
--header "Content-Type: application/x-www-form-urlencoded" \    
--header "Accept: application/json" \    
--data-urlencode "grant_type=urn:ibm:params:oauth:grant-type:apikey" \    
--data-urlencode "apikey=<somekey>" \    
"https://iam.bluemix.net/identity/token"

scalaj-http 库中,我知道我们可以添加 header,但我没有看到添加 data-urlencode 作为选项的方法。我怎样才能添加这个?我需要它才能使我的 POST 请求成功。

像这样尝试postForm

Http("https://iam.bluemix.net/identity/token")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .header("Accept", "application/json")
  .postForm(Seq(
    "grant_type" -> "urn:ibm:params:oauth:grant-type:apikey", 
    "apikey" -> "somekey"))
  .asString