John
John

Reputation: 3

Oracle REST Data Services, JSON vs HTML error responses

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

Upvotes: 0

Views: 1078

Answers (2)

John
John

Reputation: 3

Add below header in PLSQL code before printing the response message

OWA_UTIL.mime_header('application/json');

Upvotes: 0

thatjeffsmith
thatjeffsmith

Reputation: 22412

In your request include an Accept header.

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

enter image description here

Upvotes: 0

Related Questions