I am hitting my api from another service with help of endpoint in Wso2. However, I am getting the error below:
"errorCode": "0",
"errorMessage": "Error occured in the mediation of the class mediator"
Note: The error comes only for one endpoint rest all is working absolutely fine for the same service. Unable to figure out the problem.
for further detail of error I am attaching it below:
"errorDetail": "org.apache.synapse.SynapseException: Error occured in the mediation of the class mediator\n\tat
org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:102)\n\tat
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)\n\tat
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)\n\tat
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)\n\tat
org.apache.synapse.api.Resource.process(Resource.java:342)\n\tat
org.apache.synapse.api.API.process(API.java:463)\n\tat
org.apache.synapse.api.AbstractApiHandler.apiProcess(AbstractApiHandler.java:93)\n\tat
org.apache.synapse.api.AbstractApiHandler.dispatchToAPI(AbstractApiHandler.java:71)\n\tat
org.apache.synapse.api.rest.RestRequestHandler.dispatchToAPI(RestRequestHandler.java:84)\n\tat
org.apache.synapse.api.rest.RestRequestHandler.process(RestRequestHandler.java:70)\n\tat
org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:54)\n\tat
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:344)\n\tat
org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:101)\n\tat
org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:375)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:434)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:182)\n\tat
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat
java.base/java.lang.Thread.run(Thread.java:834)\nCaused by: org.apache.synapse.SynapseException:
org.json.simple.parser.ParseException\n\tat
org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:376)\n\tat
com.safaricom.mediator.RESTInteractRequestMediator.mediate(RESTInteractRequestMediator.java:139)\n\tat
org.apache.synapse.mediators.ext.ClassMediator.updateInstancePropertiesAndMediate(ClassMediator.java:178)\n\tat
org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:97)\n\t... 20
more\nCaused by: Unexpected character (<) at position 0.\n\tat
org.json.simple.parser.Yylex.yylex(Yylex.java:610)\n\tat
org.json.simple.parser.JSONParser.nextToken(JSONParser.java:269)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:118)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:81)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:75)\n\tat
com.safaricom.mediator.RESTInteractRequestMediator.mediate(RESTInteractRequestMediator.java:44)\n\
t... 22 more\n"
CodePudding user response:
It seems your client is sending an XML request body to an API that expects a JSON message, or sending the wrong Content-Type header.