Hi Vikram, You can use payload factory mediator like below in the fault sequence to achieve your requirement.
<payloadFactory media-type="json"> <format> {"Message": "Not Data Found."} </format> </payloadFactory> Thanks, /Susankha. On Thu, Jan 11, 2018 at 9:17 AM, Vinod Kavinda <vi...@wso2.com> wrote: > Hi, > This should be triggering the fault sequence of your API/Proxy or the > default fault sequence. You can capture the error in fault sequence and > construct your error message. > > Regards, > Vinod > > On Wed, Jan 10, 2018 at 7:43 PM, vikram nayak <nayak.vikr...@yahoo.in> > wrote: > >> >> Hi, >> >> Third party service which I need to consume returns “null” when it has no >> data for a particular input. >> Here is how it looks in postman when I hit third party service. >> >> [image: Inline image 1] >> [image: Inline image 2] >> >> and wso2 service console shows below erros and service gets hanged , the >> control does not come to response flow : (Error logs attached) >> >> [2018-01-10 19:34:49,145] [EI-Core] ERROR - JsonUtil #getNewJsonPayload. >> Could not save JSON payload. Invalid input stream found. MessageID: >> urn:uuid:ca4bbd52-ec0d-4fe9-9dcf-b99b5fda1b8c >> [2018-01-10 19:34:49,146] [EI-Core] ERROR - JsonStreamBuilder Error >> occurred while processing document for application/json >> java.lang.reflect.InvocationTargetException >> at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source) >> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) >> at java.lang.reflect.Method.invoke(Unknown Source) >> at org.wso2.carbon.integrator.core.json.JsonStreamBuilder.proce >> ssDocument(JsonStreamBuilder.java:69) >> at org.apache.synapse.transport.passthru.util.DeferredMessageBu >> ilder.getDocument(DeferredMessageBuilder.java:148) >> at org.apache.synapse.transport.passthru.util.RelayUtils.builld >> Message(RelayUtils.java:136) >> >> Please suggest how to handle this error. I want to throw some business >> exception like {"Message": "Not Data Found."} >> >> Regards, >> >> _______________________________________________ >> Dev mailing list >> Dev@wso2.org >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > Vinod Kavinda > Senior Software Engineer > *WSO2 Inc. - lean . enterprise . middleware <http://www.wso2.com>.* > Mobile : +94 (0) 712 415544 > Blog : http://soatechflicks.blogspot.com/ > [image: http://wso2.com/signature] > <http://wso2.com/signature> > > > _______________________________________________ > Dev mailing list > Dev@wso2.org > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Susankha Nirmala Senior Software Engineer WSO2, Inc.: http://wso2.com lean.enterprise.middleware Mobile : +94 77 593 2146 blog : https://susankhanirmala.wordpress.com/
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev