Accepted answer

Apparently a toEntity method was added to the FormData class at some point. So this now seems like the simplest solution to the problem:

val formData = FormData(combinedParams).toEntity
val r = HttpRequest(POST, url, headers, formData)


You can also use RequestBuilding:

Http().singleRequest(RequestBuilding.Post(url, formData)).flatMap(Unmarshal(_).to[String])


You can use Marshal in a for comprehension with other Futures, such as the ones you need to send the request and unmarshall the response:

val content = for {
        request <- Marshal(formData).to[RequestEntity]
        response <- Http().singleRequest(HttpRequest(method = HttpMethods.POST, uri = s"", entity = request))
        entity <- Unmarshal(response.entity).to[String]
      } yield entity

Related Query

More Query from same tag