gpt4 book ai didi

web-services - 如何在 Playframework 2/Scala 中使用 WS API 发送空正文请求?

转载 作者:行者123 更新时间:2023-12-02 00:04:47 25 4
gpt4 key购买 nike

我尝试使用 Play2/Scala WS API 向服务端点发送 HTTP POST 请求。由于HTTP POST body中没有要发送的参数,如何使用

WS.url("http://service/endpoint").post()

我尝试过不带参数的 post() 但它给了我一个错误。

Cannot write an instance of Unit to HTTP response. Try to define aWriteable[Unit]

你能帮忙解决一下吗?

提前致谢...

最佳答案

由于 post 等待实现 WriteableContentTypeOf 类型类的值,您可以使用 play.api.mvc 中的 Results.EmptyContent。 (参见API)

所以我猜

WS.url("http://service/endpoint").post(Results.EmptyContent())

应该做。 (未测试)

关于web-services - 如何在 Playframework 2/Scala 中使用 WS API 发送空正文请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15255380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com