Hi,

I customized API manager main sequence to change the default error message
according to below format.so now i am getting the error messages as below.

*PayloadFactory:*

<property name="ERROR_DETAIL" value="Unsupported Transport. The requested
resource  is not available."/>
<property name="ERROR_URL_POSTFIX" expression="$axis2:REST_URL_POSTFIX"/>
<property name="ERROR_FORMAT_LINK" value="http://errors.api.wso2.com/wso2/
"/>
 <property name="ERROR_CODE" value="403"/>

<payloadFactory media-type="json">
                 <format>
        {
                        "message":"$1",

  "_links":{
                                        "about":{
                                                "href": "$2"
                                        },

                                        "help":{
                                                "href": "$3$4"
                                        }

                                }

        }
                </format>
                <args>
                <arg xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope";
xmlns:ns3="http://org.apache.synapse/xsd"; evaluator="xml"
expression="$ctx:ERROR_DETAIL"/>
                <arg xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope";
xmlns:ns3="http://org.apache.synapse/xsd"; evaluator="xml"
expression="$ctx:ERROR_URL_POSTFIX"/>
                <arg xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope";
xmlns:ns3="http://org.apache.synapse/xsd"; evaluator="xml"
expression="$ctx:ERROR_FORMAT_LINK"/>
                <arg xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope";
xmlns:ns3="http://org.apache.synapse/xsd"; evaluator="xml"
expression="$ctx:ERROR_CODE"/>
                </args>
       </payloadFactory>


*Error Results:*

XML:

<jsonObject><error><message>The requested resource is not
available.</message><_links><about><href>HelloService1/1.0.0/greet?name=Hi</href></about><help><href>http://errors.api.wso2.com/wso2/404
<http://errors.api.aligntech.com/wso2/404></href></help></_links></error></jsonObject>

Json:

{"jsonObject":{"error":{"message":"The requested resource is not
available.","_links":{"about":{"href":"HelloService1\/1.0.0\/greet?name=Hi"},"help":{"href":"http:\/\/errors.api.wso2.com
<http://errors.api.aligntech.com>\/wso2\/404"}}}}}


Here my requirement is to remove the <jsonObject> element from the response
and display only the error message. Is there any way to do this?
Appreciate if anyone can provide some help on this.

-- 
Asanka Vithanage
Senior Software Engineer -QA
Mobile: +94 0716286708
Email: [email protected]
WSO2 Inc. www.wso2.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to