Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WSO2 API Manager Auth error content type

I have WSO2 API Manager configured and everything seems to work fine.

The only issues bothering me is that in case of an Auth exception, the API manager always returns the response with XML content type, e.g.,

<ams:fault xmlns:ams="http://wso2.org/apimanager/security"><ams:code>900904</ams:code><ams:message>Access Token Inactive</ams:message><ams:description>Access failure for API: /exchange, version: 1.0 with key: 1139a466ebfd825aca953ad7259b9f45</ams:description></ams:fault>

In case of client communicates with my web service with JSON format, the XML response will look a little bit strange.

Is there any ideas how to make API Manager provide error response in JSON format?

like image 271
user2461343 Avatar asked Oct 22 '25 15:10

user2461343


1 Answers

This has been addressed in recent versions of API Manager. Auth errors can be set to json format by adding or updating the error_message_type property in WSO2HOME/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler_.xml:

<property name="error_message_type" value="application/json"/>

I've found this also requires JSONBuilder and JSONMessageFormatter to be selected for the json content type in axis2.xml (which is the default setting).

For older versions, this article explains how to manually do the same.

like image 190
Facundo Olano Avatar answered Oct 25 '25 09:10

Facundo Olano