Home > database >  Oracle REST Data Services, JSON vs HTML error responses
Oracle REST Data Services, JSON vs HTML error responses

Time:06-16

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

CodePudding user response:

In your request include an Accept header.

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

enter image description here

CodePudding user response:

Add below header in PLSQL code before printing the response message

OWA_UTIL.mime_header('application/json');

  • Related