【发布时间】:2017-03-16 20:00:07
【问题描述】:
我正在查询一个搜索 api,我需要将 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 发送到帖子正文中吗?
【问题讨论】:
-
你需要像 jackson 或 json4s 这样的“marshaller”...