When I execute a POST request using curl, it looks this way:
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"
In the scalaj-http
library, I know we can add header
, but I don't see a way to add data-urlencode
as an option. How can I add this? I need it for my POST Request to be successful.
Try postForm
like so
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