org.http4s.client Post with header and UriForm

1.6k Views Asked by At

With using org.http4s.client can't find how I can send headers and UriForm together with Post request.

import org.http4s.client.dsl.io._
import org.http4s.Method._

val lstHeader: List[Header] = List(
  Header("Accept", "application/json")
  , Header("Accept-Charset", "utf-8")
  , Header("Accept-Encoding", "gzip")
)

val formData :UrlForm = UrlForm(
  "username" -> "user",
  "enc_password" -> "password",
  "queryParams" -> "{}",
  "optIntoOneTap" -> "false"
)

val req1 = POST(
  formData,
  uri"https://www.instagram.com/accounts/login/ajax/"
)

val req2: Request[IO] = Request[IO](
  Method.POST,
  uri"https://www.instagram.com/accounts/login/ajax/",
  HttpVersion.`HTTP/2.0`,
  Headers(lstHeader)
)

req1 without my headers req2 without form data

Thanks

1

There are 1 best solutions below

0
On

I found

val req2: Request[IO] = Request[IO](
  Method.POST,
  uri"https://www.instagram.com/accounts/login/ajax/",
  HttpVersion.`HTTP/2.0`,
  Headers(lstHeader)
).withEntity(formData)