Hi All
Is it possible to override the PAS and Spring framework to send back JSON on a 401 unauthorized instead of the default page?
Thanks
Christian.
Hi Christian,
If you set Accept header to application/json, I believe you will be returned a json instead of default page.
Thanks,
Navneet
Hi Christian,
If you set Accept header to application/json, I believe you will be returned a json instead of default page.
Thanks,
Navneet
This may not apply, but I'd like to add that if you are accessing the PAS OE instance through IIS using the AJP13 protocol (via BonCode or the Apache AJP13 connector for IIS), you will need to add the following to the <system.webServer> section of the web.config file for the IIS site, to have the JSON pass through to the client. Otherwise, IIS intercepts the response and replaces the body with it's default error body for the response 'Status Code'.
<httpErrors existingResponse="PassThrough" />
Thanks for the tip. I have noticed it sends back malformed JSON in OE 11.6.4.
exception_class bwing invalid
e.g.
{ "error_code": 401
, "status_text": "401 - Unauthorized: authentication failed due to bad credentials - GET /web/Catalog/OEAA.Repairs.Params.JobAbandonReasonBusinessEntity"
, "error_details": {"remote_user": "null", "user_principal": "null", "url_scheme": "https", "remote_addr": "127.0.0.1", "server_name": "localhost", "product_type": "dev", "http_status": 401 , "error_detail": "Full authentication is required to access this resource"}
, "debug_details": { "http_method": "GET", "web_application": "/ROOT", "transport": "OEWebServlet", "request_url": "/web/Catalog/OEAA.Repairs.Params.JobAbandonReasonBusinessEntity", "path_info": "null", "servlet": "OEWebServlet", "uri": "/web/Catalog/OEAA.Repairs.Params.JobAbandonReasonBusinessEntity", "exception_class": "" "exception_message": "", "exception_stack_trace": }
}