crockpotveggies
crockpotveggies

Reputation: 13320

Exact syntax for multiple headers in Play! 2.0 WS request?

Trying to add multiple headers to a Scala Play! WS Request:

WS
.url(requestUri)
.withHeaders("Authorization" -> ("Oauth %s" format(cred.authorizedToken)),
    "Content-Type" -> "application/json")
.post(httpBody.get)

However it is currently failing. What's the proper syntax? I've tried multiple approaches but the compiler complains about java strings. Thanks!

Upvotes: 2

Views: 2488

Answers (1)

Julien Lafont
Julien Lafont

Reputation: 7877

Your approach seems valid according to the documentation

Ok("Hello World!").withHeaders(
  CACHE_CONTROL -> "max-age=3600", 
  ETAG -> "xx"
)

And the method definition validate your code too :

def withHeaders(hdrs: (String, String)*)
// Parameters are infinite couples of String

Upvotes: 3

Related Questions