java - REST:告诉客户端仅发送 csv 和文本格式

标签 java rest web-services

在restfull WS中,如何告诉客户端仅发送csv和文本格式文件。

content-type header 中,客户端设置发送请求的格式,在 Accept header 中,客户端设置要接受响应的格式。

但是如何告诉客户端仅发送 content-type csv 或文件?这是通过一些文档吗?

最佳答案

415状态码似乎适合这种情况:

6.5.13. 415 Unsupported Media Type

The 415 (Unsupported Media Type) status code indicates that the origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource. The format problem might be due to the request's indicated Content-Type or Content-Encoding, or as a result of inspecting the data directly.

响应负载可以包含服务器支持的媒体类型列表。

关于java - REST:告诉客户端仅发送 csv 和文本格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54072518/

相关文章:

node.js - 在线托管 REST Composer 服务器?

java - 使用 responseContainer Swagger 注释属性标记非平面容器

javascript - 从外部网络服务获取图像并将其传递给另一个快速 js 路由

c# - 签署外发消息

java - Java 中的 XML 验证 - 为什么会失败?

java - 将源的子文件复制到 Java 中的目标

java - 尝试使用 Apache POI 从 Excel 工作簿获取公式时出错

java - 从 Rest API Java 下载 ODS/XLS

c# - 什么会生成WebServiceRef Reference.cs文件?

java - 吉斯 : How to customize the bindings of a third-party Module?