Akka Http Client Set Cookie on a HttpRequest <p>I am trying to make a GET request to a REST web service using Akka Http Client.</p> <p>I am not able to figure out how do I set a cookie on the request before I make the GET.</p> <p>I searched the web and I found ways to read the cookie on the server side. but I could not find anything which showed me how to set the cookie on the client side request.</p> <p>Based on my own research I tried the following approach to set a cookie on http request</p> <pre><code>import akka.actor.ActorSystem import akka.http.scaladsl.Http import akka.http.scaladsl.model._ import akka.http.scaladsl.unmarshalling.Unmarshal import akka.stream.scaladsl.{Sink, Source} import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport import akka.http.scaladsl.model.headers.HttpCookie import akka.stream.ActorMaterializer import spray.json._ import scala.util.{Failure, Success} case class Post(postId: Int, id: Int, name: String, email: String, body: String) trait JsonSupport extends SprayJsonSupport with DefaultJsonProtocol { implicit val postFormat = jsonFormat5(Post.apply) } object AkkaHttpClient extends JsonSupport{ def main(args: Array[String]) : Unit = { val cookie = headers.`Set-Cookie`(HttpCookie(name="foo", value="bar")) implicit val system = ActorSystem("my-Actor") implicit val actorMaterializer = ActorMaterializer() implicit val executionContext = system.dispatcher val mycookie = HttpCookie(name="foo", value="bar") val httpClient = Http().outgoingConnection(host = "jsonplaceholder.typicode.com") val request = HttpRequest(uri = Uri("/comments"), headers = List(cookie)) val flow = Source.single(request) .via(httpClient) .mapAsync(1)(r =&gt; Unmarshal(r.entity).to[List[Post]]) .runWith(Sink.head) flow.andThen { case Success(list) =&gt; println(s"request succeded ${list.size}") case Failure(_) =&gt; println("request failed") }.andThen { case _ =&gt; system.terminate() } } } </code></pre> <p>But this gives an error</p> <pre><code>[WARN] [08/05/2016 10:50:11.134] [my-Actor-akka.actor.default-dispatcher-3] [akka.actor.ActorSystemImpl(my-Actor)] HTTP header 'Set-Cookie: foo=bar' is not allowed in requests </code></pre>