I am building a webservice request that submits some data to a 3rd party service we use:
val promise = WS.url("http://example.com/api/xxx/testers?api_key=%s" format(prefineryAPIKey)).post(requestBody)
val data = promise.value.get.body
The variable requestBody is XML content and I need to send this post with "Content-Type: text/xml". How do I set that inside the webservice? Does it work like Play!’s result by chaining .as("text/xml")?
Thanks
Found it! I had to dig around the API docs and decrypt some of the compiler errors, but basically the above will look like:
When you call WS you are putting together a
WSRequestHolder. The docs for WSRequest are here:http://www.playframework.org/documentation/api/2.0/scala/index.html#play.api.libs.ws.WS$$WSRequestHolder