3
我正在查詢一個搜索api,我需要將json中的查詢參數添加到發佈請求中。akka http - 如何將json數據添加到發佈請求?
val headers: scala.collection.immutable.Seq[HttpHeader] = scala.collection.immutable.Seq(
RawHeader("accept", "application/json"),
RawHeader("authorization", "xxxxxxxxxxxxxxxxxxxx"),
RawHeader("content-type", "application/json"),
RawHeader("x-customer-id", "123456789")
)
val formData = FormData(Map(
"Keywords" -> "query", "Count" -> "25"
))
val request = HttpRequest(HttpMethods.POST, "https://api.xxx.com/services/xxx/v1/search?client_id=xxxxxx", headers, formData.toEntity)
將使用formData.toEntity
發送它作爲JSON在帖子的主體?
你需要一個「編組」像傑克遜或json4s ... –