score:31
Since post
awaits a value that implements the Writeable
and ContentTypeOf
type classes,
you can use the Results.EmptyContent
from play.api.mvc
. (See API)
So I guess
WS.url("http://service/endpoint").post(Results.EmptyContent())
should do. (Didnt test)
score:2
As of Play 2.8, you cannot use the WSRequest.post(body)
methods with an empty body, because the BodyWritable
trait requires a non-empty Content-Type
Instead, you can do ws.url(u).execute("POST")
to send an HTTP POST request with no body.
score:29
For Play 2.6 and after, you have to use play.api.libs.ws.EmptyBody
.
import play.api.libs.ws.{EmptyBody, WSClient}
WS.url("http://service/endpoint).post(EmptyBody)
Typical error is:
Cannot find an instance of play.api.mvc.Results.EmptyContent to WSBody. Define a BodyWritable[play.api.mvc.Results.EmptyContent] or extend play.api.libs.ws.ahc.DefaultBodyWritables
Source: stackoverflow.com
Related Query
- How to http post with an empty body request using WS API in Playframework 2 / Scala?
- How to send HTTP request using Akka with SSL certificates
- How to read JSON body from Akka HTTP POST request and send the final response as JSON array
- HTTP Post Request in Scala using variables in JSON body
- Akka http add header to POST request with body
- Send POST request with parameters in body via Play WS API
- How to make a POST request passing JSON as body with Bee Client (Scala)?
- How to send cookie with http request in Scala without using any other library?
- Using scala spark how to print just the response body value returned from a HTTP post call
- How to do a GET Request on a REST API which has request Body using Scala?
- How to generate multivalue map with random values and inject into request body using a feeder in Gatling
- Send POST request with a body using scala and play framework
- How to get the body of post request in Scalatra?
- Idiomatic way to create a basic HTTP Post request with Akka HTTP
- Scala play http filters: how to find the request body
- How do I create a POST request with form field content with Spray?
- Sending POST Request to Twitter API with Play Framework 2.0
- How to print http request when using Dispatch and Scala
- How to get http request header info from the server side with spray RestAPI
- Playframework test. FakeRequest sent with empty body always (scala)
- How to make proper https request using Finagle to Telegram API
- http get request with body
- Spark Send DataFrame as body of HTTP Post request
- Making a HTTP API server asynchronous with Future, how does it make it non-blocking?
- How can you sign a POST with OAuth1.0a using scala play?
- log request body using scala http filter
- Akka HTTP how to POST singleRequest with Content-Type application/x-www-form-urlencoded
- Post request with Akka http
- How to send a file and json payload together in Post Request with akka-http
- How do I read response headers + body from single POST using scala's dispatch lib
More Query from same tag
- Converting synthetic function "<<" in Scala to MongoDB command
- RestartSource masking the materialized value for the wrapped source?
- How to programmatically create Map of Map of Map nested in up to N times in Java/Scala
- how should I express the hdfs path in spark textfile?
- Link Multiple Either's
- Polymorphism not working as expected in scala
- Wrap argThat in a named function
- Play framework route file compilation warning: local val in method at is never used
- play framework 2.4.2 client connection remains open
- Scala: Shapeless Generic with universal traits
- How does the Seq shorthand for Scala actually work?
- List in form outputs weird error in Play 2.1.3
- Why does Scala function allow subclass parameter when specifyied super class parameter
- Transform sequence of strings to join columns
- What are the differences between pre-built and user-provided hadoop on spark download page?
- How to find skipped spark job
- Pattern Matching to check if string is null or empty
- Scala Map's get vs apply operation: "type mismatch"
- Change Flyway resources location for scala unit test
- Spark: reduce/aggregate by key
- Apache Spark: How to perform cartesian product in map function of XML nodes
- Is there something like AutoMapper for Scala?
- Can I set cookies before returning an action in Play Framework 2?
- In Scala, how to refactor codes with Option class like this?
- Scala - use cases for tuples?
- Scala by Example - type bounds parametrized function compiler complains
- Is there a way to use ++ on Int in scala?
- RabbitMQ only once getting message count from queue
- Select all non-null column names per row in spark
- Resolve two sbt imports with the same classes