Decoder.of(“content/type”)(response => Validated.valid(_.content))
I think
```def createSession(client: Client): String = {
val d = SSession("spark", "spark1")
val headers = """{'Content-Type': 'application/json'}"""
val req = client.post("/sessions").withContent(d, "application/json")
Await.result {
req.send[Response]() map {
response => response.contentString
}
}
}```
I'm attempting to add a postF function that will allow me to post without content, something like:
def postF[
ResponseType
](
endpoint: String,
header: (String, String) = defaultHeader
)(
implicit
decoder: Decoder[ResponseType]
): Future[Either[HttpResponseError, ResponseType]] = {
client
.post(s"/$endpoint")
.accept[Coproduct.`"application/json"`.T]
.withHeaders(header)
.send[ResponseType]()
.map(Right(_))
.handle({ case error: Throwable => Left(getHttpResponse(error)) })
}
but I'm getting an error:
[error] 1. If the request is a POST, PUT, or PATCH request:
[error] a. The request requires a Content-Type to be defined, but one was not defined (using the withContent method)
[error] b. An Encoder is required for the request's Content-Type, but one was not available in implicit scope. This is
[error] usually a matter of importing the right module to obtain the Encoder instance.
[error] 2. Something is missing from featherbed
[error] .send[ResponseType]()
[error] ^