Oracle REST数据服务,JSON vs HTML错误响应

发布于 2025-02-06 23:29:35 字数 393 浏览 1 评论 0原文

我有一个带有Post方法的REST API,它可以正常工作。但是在自定义400状态代码错误响应中,内容类型似乎是HTML而不是JSON。

样本:

400,79ms,23个字节

API_STATUS_CODE:SIM400-05 连接:关闭 content-type:文本/html ; charset = utf-8 日期:2022年6月13日星期一14:31:15 GMT 转移编码:块 X-ords_debug:错误

无效帐号

我尝试在我的请求标题中添加“ REST-FRAMEWORK-REVER”为4,但错误响应仍然是HTML而不是JSON。

Oracle Apex:21.1 Oracle Ords:21

I have a REST API with POST method and it works fine. But on a custom 400 status code error response the content-type seems to be html rather than json.

Sample:

400 , 79ms, 23 bytes

api_status_code: SIM400-05
connection: close
content-type: text/html;charset=UTF-8
date: Mon, 13 Jun 2022 14:31:15 GMT
transfer-encoding: chunked
x-ords_debug: false

Invalid Account Number

I have tried adding "REST-Framework-Version" as 4 in my request header but still the error response is as html and not json.

Oracle APEX: 21.1
Oracle ORDS: 21

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔少女心 2025-02-13 23:29:35

在您的要求中包括一个接受标头。

curl -X POST --header 'Accept: application/json'

In your request include an Accept header.

curl -X POST --header 'Accept: application/json'

enter image description here

酒与心事 2025-02-13 23:29:35

在打印响应消息

owa_util.mime_header('application/json')之前,请在PLSQL代码中添加下面的标题。

Add below header in PLSQL code before printing the response message

OWA_UTIL.mime_header('application/json');

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文