scalaj / scalaj-http

Simple scala wrapper for HttpURLConnection. OAuth included.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

data-urlencode option

Sparker0i opened this issue · comments

When I try to execute a POST request using curl for an endpoint, the request looks like this:

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"

This library contains header() to specify the headers. What shall I use to provide the data-urlencode option? Without this my request will not work

That's a standard form encoding:

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