当我使用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请求成功。
发布于 2019-08-12 21:49:48
像这样尝试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"))
.asStringhttps://stackoverflow.com/questions/57461415
复制相似问题