Bad Request - Invalid URL using a call towards an endpoint - wso2

I have been trying to understand why this is happening. My ESB does a call towards https://login.microsoftonline.com/ in order to obtain a token which I use to do a call towards an endpoint. The problem is that when a call is sent with my ESB I get:
[2021-11-01 14:42:17,226] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "HTTP/1.1 400 Bad Request[\r][\n]"
[2021-11-01 14:42:17,226] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Content-Type: text/html; charset=us-ascii[\r][\n]"
[2021-11-01 14:42:17,227] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Date: Mon, 01 Nov 2021 12:42:16 GMT[\r][\n]"
[2021-11-01 14:42:17,228] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Connection: close[\r][\n]"
[2021-11-01 14:42:17,228] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Content-Length: 324[\r][\n]"
[2021-11-01 14:42:17,229] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "[\r][\n]"
[2021-11-01 14:42:17,230] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">[\r][\n]"
[2021-11-01 14:42:17,231] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "<HTML><HEAD><TITLE>Bad Request</TITLE>[\r][\n]"
[2021-11-01 14:42:17,231] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>[\r][\n]"
[2021-11-01 14:42:17,232] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "<BODY><h2>Bad Request - Invalid URL</h2>[\r][\n]"
[2021-11-01 14:42:17,233] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "<hr><p>HTTP Error 400. The request URL is invalid.</p>[\r][\n]"
[2021-11-01 14:42:17,234] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "</BODY></HTML>[\r][\n]"
[2021-11-01 14:42:17,259] ERROR {RelayUtils} - Error while building Passthrough stream org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,50]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:165)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:169)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:122)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:152)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:95)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:260)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:809)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:309)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:583)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:197)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:285)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,50]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.startDTD(BasicStreamReader.java:2487)
at com.ctc.wstx.sr.BasicStreamReader.nextFromPrologBang(BasicStreamReader.java:2403)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2063)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 19 more
[2021-11-01 14:42:17,261] ERROR {SequenceMediator} - {api:smp-serviceability-check-api} Error while building message. Error while building Passthrough stream org.apache.axis2.AxisFault: Error while building Passthrough stream
at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:452)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:215)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:122)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:152)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:95)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:260)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:809)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:309)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:583)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:197)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:285)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,50]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:165)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:169)
... 14 more
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,50]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.startDTD(BasicStreamReader.java:2487)
at com.ctc.wstx.sr.BasicStreamReader.nextFromPrologBang(BasicStreamReader.java:2403)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2063)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 19 more
[2021-11-01 14:42:17,277] INFO {LogMediator} - {api:smp-serviceability-check-api} To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:dcbc17c0-5dc7-46d5-b7f6-db5f3e571506, Direction: request, MESSAGE = An unexpected error occured, message = Error while building message. Error while building Passthrough stream, message = 601000, message = org.apache.synapse.SynapseException: Error while building message. Error while building Passthrough stream
at org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:376)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:154)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:95)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:260)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:809)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:309)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:583)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:197)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:285)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.axis2.AxisFault: Error while building Passthrough stream
at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:452)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:215)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:122)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:152)
... 12 more
Caused by: org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,50]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:165)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:169)
... 14 more
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
at [row,col {unknown-source}]: [1,50]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.startDTD(BasicStreamReader.java:2487)
at com.ctc.wstx.sr.BasicStreamReader.nextFromPrologBang(BasicStreamReader.java:2403)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2063)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 19 more
, message = org.apache.synapse.SynapseException: Error while building message. Error while building Passthrough stream, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>
I went through a lot of scenarios where there were unwanted Cookies, Header Parameters, bad Content Type and etc. which I removed using fields bellow:
<!-- Chaning ContentType to none-->
<property name="ContentType" scope="axis2" type="STRING" value="none"/>
<!-- Removing custom Header Params -->
<property action="remove" name="x-ms-ests-server" scope="transport"/>
<property action="remove" name="x-ms-request-id" scope="transport"/>
<!-- Removing all the header params and cookies -->
<property action="remove" name="EXCESS_TRANSPORT_HEADERS" scope="axis2"/>
<property action="remove" name="TRANSPORT_HEADERS" scope="axis2"/>
<property action="remove" name="Set-Cookie" scope="transport"/>
<!-- Removing /query parameter received by the API -->
<property name="REST_URL_POSTFIX" scope="axis2" type="STRING" value=""/>
At the end I just created a simple call request that goes directly to the endpoint with Hardcoded URL, Bearer token and everything. ( It doesn't get the token, it skips that part so that the whole thing is just one call towards an endpoint ).
<property name="Authorization" scope="transport" type="STRING" value="Bearer TOKEN_IS_HERE"/>
<property name="REST_URL_POSTFIX" scope="axis2" type="STRING" value=""/>
<property action="remove" name="ContentType" scope="axis2"/>
<property name="messageType" scope="axis2" type="STRING" value="none"/>
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="GET"/>
<call>
<endpoint>
<address statistics="enable" trace="enable" uri="https://sub-domain.dns.net?qparam=999999999">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</call>
And I still keep getting Bad Request - Invalid URL. Using postman the direct call works without a problem and I copy all the parameters from the MI log.. I have also tested each Parameter that was sent before simplifying the code, by manually adding them in the postman request to see if it will break but none of them did. I tried different messageTypes and ContentTypes but same thing.
Here is how my get call looks like in the wire logs
[2021-11-01 14:57:40,243] INFO {TRACE_LOGGER} - Sending message through endpoint : null resolving to address = https://sub-domain.dns.net?qparam=999999999
[2021-11-01 14:57:40,243] INFO {TRACE_LOGGER} - SOAPAction: null
[2021-11-01 14:57:40,245] INFO {TRACE_LOGGER} - WSA-Action: null
[2021-11-01 14:57:40,254] INFO {TimeoutHandler} - This engine will expire all callbacks after GLOBAL_TIMEOUT: 120 seconds, irrespective of the timeout action, after the specified or optional timeout
[2021-11-01 14:57:41,045] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "GET ?qparam=999999999 HTTP/1.1[\r][\n]"
[2021-11-01 14:57:41,046] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Authorization: Bearer THE_TOKEN[\r][\n]"
[2021-11-01 14:57:41,047] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Accept: */*[\r][\n]"
[2021-11-01 14:57:41,047] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Postman-Token: 69862f3a-1404-4f4b-b6a7-cc67d1197b5c[\r][\n]"
[2021-11-01 14:57:41,048] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2021-11-01 14:57:41,049] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Content-Type: none[\r][\n]"
[2021-11-01 14:57:41,049] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Host: sub-domain.dns.net[\r][\n]"
[2021-11-01 14:57:41,049] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Connection: Keep-Alive[\r][\n]"
[2021-11-01 14:57:41,050] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2021-11-01 14:57:41,050] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "[\r][\n]"
Other things I tried are changing the call endpoint to
<endpoint>
<http method="get" uri-template="https://sub-domain.dns.net?qparam=999999999"/>
</endpoint>
but didn't work. Any ideas are really apricated why this is happening.
Edit: Tested with Free APIs in http and https and they work..
HTTP:
[2021-11-02 11:13:11,121] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "GET /users?_limit=2 HTTP/1.1[\r][\n]"
[2021-11-02 11:13:11,122] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "Accept: */*[\r][\n]"
[2021-11-02 11:13:11,123] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "Postman-Token: 945d1aa2-9553-42dd-a471-e9dd106f09df[\r][\n]"
[2021-11-02 11:13:11,125] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2021-11-02 11:13:11,126] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "eti-organizationid: org634bbfb6[\r][\n]"
[2021-11-02 11:13:11,126] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "Content-Type: none[\r][\n]"
[2021-11-02 11:13:11,127] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "Host: fakeapi.jsonparseronline.com[\r][\n]"
[2021-11-02 11:13:11,128] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "Connection: Keep-Alive[\r][\n]"
[2021-11-02 11:13:11,129] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2021-11-02 11:13:11,129] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 << "[\r][\n]"
[2021-11-02 11:13:11,254] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "HTTP/1.1 200 OK[\r][\n]"
[2021-11-02 11:13:11,255] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Server: Cowboy[\r][\n]"
[2021-11-02 11:13:11,256] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Connection: keep-alive[\r][\n]"
[2021-11-02 11:13:11,256] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "X-Powered-By: Express[\r][\n]"
[2021-11-02 11:13:11,257] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Vary: Origin, Accept-Encoding[\r][\n]"
[2021-11-02 11:13:11,257] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Access-Control-Allow-Credentials: true[\r][\n]"
[2021-11-02 11:13:11,257] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Cache-Control: no-cache[\r][\n]"
[2021-11-02 11:13:11,258] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Pragma: no-cache[\r][\n]"
[2021-11-02 11:13:11,258] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Expires: -1[\r][\n]"
[2021-11-02 11:13:11,258] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "X-Total-Count: 50[\r][\n]"
[2021-11-02 11:13:11,259] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Access-Control-Expose-Headers: X-Total-Count[\r][\n]"
[2021-11-02 11:13:11,259] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "X-Content-Type-Options: nosniff[\r][\n]"
[2021-11-02 11:13:11,259] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Content-Type: application/json; charset=utf-8[\r][\n]"
[2021-11-02 11:13:11,260] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Etag: W/"4c9-6aU1Y/ePEQDvH83MhgvZYvJUcUg"[\r][\n]"
[2021-11-02 11:13:11,261] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Content-Encoding: gzip[\r][\n]"
[2021-11-02 11:13:11,261] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Date: Tue, 02 Nov 2021 09:13:11 GMT[\r][\n]"
[2021-11-02 11:13:11,261] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Transfer-Encoding: chunked[\r][\n]"
[2021-11-02 11:13:11,262] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "Via: 1.1 vegur[\r][\n]"
[2021-11-02 11:13:11,262] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "[\r][\n]"
[2021-11-02 11:13:11,263] DEBUG {wire} - HTTP-Sender I/O dispatcher-1 >> "a[\r][\n]"
...
HTTPS:
[2021-11-02 11:07:23,301] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "GET /entries?title=Open%20Skills HTTP/1.1[\r][\n]"
[2021-11-02 11:07:23,302] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Accept: */*[\r][\n]"
[2021-11-02 11:07:23,303] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Postman-Token: a4c8fdcf-4957-46b1-8b35-589215ac89d6[\r][\n]"
[2021-11-02 11:07:23,305] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2021-11-02 11:07:23,306] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "eti-organizationid: org634bbfb6[\r][\n]"
[2021-11-02 11:07:23,306] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Content-Type: none[\r][\n]"
[2021-11-02 11:07:23,307] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Host: api.publicapis.org[\r][\n]"
[2021-11-02 11:07:23,309] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "Connection: Keep-Alive[\r][\n]"
[2021-11-02 11:07:23,310] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2021-11-02 11:07:23,311] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 << "[\r][\n]"
[2021-11-02 11:07:23,445] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "HTTP/1.1 200 OK[\r][\n]"
[2021-11-02 11:07:23,445] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Access-Control-Allow-Origin: *[\r][\n]"
[2021-11-02 11:07:23,446] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Content-Length: 245[\r][\n]"
[2021-11-02 11:07:23,447] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Content-Type: application/json[\r][\n]"
[2021-11-02 11:07:23,448] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Date: Tue, 02 Nov 2021 09:07:23 GMT[\r][\n]"
[2021-11-02 11:07:23,448] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "Server: Caddy[\r][\n]"
[2021-11-02 11:07:23,449] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "X-Rate-Limit-Duration: 1[\r][\n]"
[2021-11-02 11:07:23,450] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "X-Rate-Limit-Limit: 10.00[\r][\n]"
[2021-11-02 11:07:23,452] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "X-Rate-Limit-Request-Forwarded-For: 20.75.122.9[\r][\n]"
[2021-11-02 11:07:23,454] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "X-Rate-Limit-Request-Remote-Addr: 172.17.0.1:49674[\r][\n]"
[2021-11-02 11:07:23,454] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "[\r][\n]"
[2021-11-02 11:07:23,454] DEBUG {wire} - HTTPS-Sender I/O dispatcher-1 >> "{"count":1,"entries":[{"API":"Open Skills","Description":"Job titles, skills and related jobs data","Auth":"","HTTPS":false,"Cors":"unknown","Link":"https://github.com/workforce-data-initiative/skills-api/wiki/API-Overview","Category":"Jobs"}]}[\n]"
[2021-11-02 11:07:23,478] INFO {LogMediator} - {api:smp-serviceability-check-api} Finished.......... = Hello, Result = {"count":1,"entries":[{"API":"Open Skills","Description":"Job titles, skills and related jobs data","Auth":"","HTTPS":false,"Cors":"unknown","Link":"https://github.com/workforce-data-initiative/skills-api/wiki/API-Overview","Category":"Jobs"}]}
[2021-11-02 11:07:23,482] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "HTTP/1.1 200 OK[\r][\n]"
[2021-11-02 11:07:23,483] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "X-Rate-Limit-Request-Forwarded-For: 20.75.122.9[\r][\n]"
[2021-11-02 11:07:23,483] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "Server: Caddy[\r][\n]"
[2021-11-02 11:07:23,484] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "Access-Control-Allow-Origin: *[\r][\n]"
[2021-11-02 11:07:23,485] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "X-Rate-Limit-Duration: 1[\r][\n]"
[2021-11-02 11:07:23,486] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "Access-Control-Allow-Methods: GET[\r][\n]"
[2021-11-02 11:07:23,487] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "X-Rate-Limit-Limit: 10.00[\r][\n]"
[2021-11-02 11:07:23,487] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "X-Rate-Limit-Request-Remote-Addr: 172.17.0.1:49674[\r][\n]"
[2021-11-02 11:07:23,488] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "Access-Control-Allow-Headers: [\r][\n]"
[2021-11-02 11:07:23,488] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2021-11-02 11:07:23,489] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "Date: Tue, 02 Nov 2021 09:07:23 GMT[\r][\n]"
[2021-11-02 11:07:23,489] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "Transfer-Encoding: chunked[\r][\n]"
[2021-11-02 11:07:23,490] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "Connection: keep-alive[\r][\n]"
[2021-11-02 11:07:23,490] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "[\r][\n]"
[2021-11-02 11:07:23,491] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "f5[\r][\n]"
[2021-11-02 11:07:23,492] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "{"count":1,"entries":[{"API":"Open Skills","Description":"Job titles, skills and related jobs data","Auth":"","HTTPS":false,"Cors":"unknown","Link":"https://github.com/workforce-data-initiative/skills-api/wiki/API-Overview","Category":"Jobs"}]}[\n]"
[2021-11-02 11:07:23,493] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "[\r][\n]"
[2021-11-02 11:07:23,493] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "0[\r][\n]"
[2021-11-02 11:07:23,494] DEBUG {wire} - HTTP-Listener I/O dispatcher-1 << "[\r][\n]"
...
I guess there might be something wrong with the target endpoint even if it works with Postman..
Integration Studio 7.2.0
Micro Integrator 1.2.0

This issue was resolved. The problem was that https://sub-domain.dns.net?qparam=999999999 was using a json server with base configurations. It was working properly with Postman but for some reason it wasn't working with wso2 calls from MI. The issue was resolved on the client side with the proper configuration of the json server.

Related

Custom Basic Auth not working in WSO2 EI 6.5.0 - ERROR: java.lang.ArrayIndexOutOfBoundsException: 1

I am trying to implement Basic Auth in WSO2 EI 6.5.0.
Below mentioned Class Mediator code is bundled and placed it into <WSO2EI_HOME>/lib and product restart done.
Lib:
CustomBasicAuth:
package com.basic.auth.handler;
import org.apache.commons.codec.binary.Base64;
import org.apache.synapse.MessageContext;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.core.axis2.Axis2Sender;
import org.apache.synapse.rest.Handler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Map;
public class CustomBasicAuth implements Handler {
private static final Log log = LogFactory.getLog(CustomBasicAuth.class);
public void addProperty(String s, Object o) {
//To change body of implemented methods use File | Settings | File Templates.
}
public Map getProperties() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public boolean handleRequest(MessageContext messageContext) {
log.info("Inside CustomBasicAuth Class **** " );
org.apache.axis2.context.MessageContext axis2MessageContext
= ((Axis2MessageContext) messageContext).getAxis2MessageContext();
Object headers = axis2MessageContext.getProperty(
org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
if (headers != null && headers instanceof Map) {
Map headersMap = (Map) headers;
if (headersMap.get("Authorization") == null) {
headersMap.clear();
axis2MessageContext.setProperty("HTTP_SC", "401");
headersMap.put("WWW-Authenticate", "Basic realm=\"WSO2 ESB\"");
axis2MessageContext.setProperty("NO_ENTITY_BODY", new Boolean("true"));
messageContext.setProperty("RESPONSE", "true");
messageContext.setTo(null);
Axis2Sender.sendBack(messageContext);
return false;
} else {
String authHeader = (String) headersMap.get("Authorization");
if (processSecurity(authHeader)) {
return true;
} else {
headersMap.clear();
axis2MessageContext.setProperty("HTTP_SC", "403");
axis2MessageContext.setProperty("NO_ENTITY_BODY", new Boolean("true"));
messageContext.setProperty("RESPONSE", "true");
messageContext.setTo(null);
Axis2Sender.sendBack(messageContext);
return false;
}
}
}
return false;
}
public boolean handleResponse(MessageContext messageContext) {
return true;
}
public boolean processSecurity(String credentials) {
log.info("encoded credentials**** " + credentials);
String decodedCredentials = new String(new Base64().decode(credentials.getBytes()));
log.info("decoded Credentials**** " + decodedCredentials);
String username = decodedCredentials.split(":")[0];
String password = decodedCredentials.split(":")[1];
if ("wso2user".equals(username) && "wso2user".equals(password)) {
return true;
} else {
return false;
}
}
}
When I invoke API, below ERROR found in wso2carbon log file
Wire Log:
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "POST /basicauthapi HTTP/1.1[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Authorization: Basic d3NvMnVzZXI6d3NvMnVzZXI=[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Content-Type: application/json[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "User-Agent: PostmanRuntime/7.30.0[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Accept: */*[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Cache-Control: no-cache[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Postman-Token: 330c0efb-1ded-41ca-b078-81a0869604a5[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Host: 192.168.43.128:8281[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Connection: keep-alive[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "Content-Length: 22[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "{[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> " "Test":"API"[\r][\n]"
[2023-01-16 17:21:26,873] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 >> "}"
[2023-01-16 17:21:26,904] [] ERROR - ServerWorker Error processing POST request for : /basicauthapi.
java.lang.ArrayIndexOutOfBoundsException: 1
at com.basic.auth.handler.CustomBasicAuth.processSecurity(CustomBasicAuth.java:73)
at com.basic.auth.handler.CustomBasicAuth.handleRequest(CustomBasicAuth.java:47)
at org.apache.synapse.rest.API.process(API.java:357)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:135)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:113)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:325)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:92)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:338)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:383)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:152)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "HTTP/1.1 500 Internal Server Error[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "Date: Mon, 16 Jan 2023 11:51:26 GMT[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "Transfer-Encoding: chunked[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "Connection: keep-alive[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "46[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "{"Fault":{"faultcode":"soapenv:Server","faultstring":1,"detail":null}}[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "0[\r][\n]"
[2023-01-16 17:21:26,920] [] DEBUG - wire HTTP-Listener I/O dispatcher-1 << "[\r][\n]"
WSO2 EI API:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/basicauthapi" name="BasicAuthAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<log level="custom">
<property name="====BasicAuthAPI" value="caleed====="/>
</log>
<payloadFactory media-type="json">
<format>{"Status":"success"}</format>
<args/>
</payloadFactory>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
<handlers>
<handler class="com.basic.auth.handler.CustomBasicAuth"/>
</handlers>
</api>
POSTMAN HIT:
Referrence link
Please let me know why custom basic auth not working.
When you extract the Auth header like String authHeader = (String) headersMap.get("Authorization"); you will get the value as Basic d3NvMnVzZXI6d3NvMnVzZXI=. This is not a valid Base64 encoded value, hence when you try to decode the value (new Base64().decode(credentials.getBytes())) it's failing, eventually throwing an error when trying to split(decodedCredentials.split(":")[0]) the credentials string.
So from the Auth header, you need to extract the credentials part. Multiple ways to do this. Following is using substring. Update the credentials extraction part to following.
String authHeader = (String) headersMap.get("Authorization").substring(6).trim();
On a different note, this code needs improvements and better error handling. For example, what if the Header is invalid? What if the password/username is missing? What if the encoding is wrong?
Update
It seems the product already packs a Auth handler by default. Which authenticates using the connected userstore. Hence you should be able to use this as well.
<handlers>
<handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
</handlers>
As suggested by #ycr, I have created required User(ie wso2user) in WSO2 EI Management console and assign required Role(ie admin)
Added org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler as Auth Handler inside API.
API:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/basicauthapi" name="BasicAuthAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<log level="custom">
<property name="====BasicAuthAPI" value="caleed====="/>
</log>
<payloadFactory media-type="json">
<format>{"Status":"success"}</format>
<args/>
</payloadFactory>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
<handlers>
<handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
</handlers>
</api>
Post above changes, API hits happen as expected shown below.

To Merge CSV Files in WSO2 EI 6.6.0 using file connector 2.0.24

I am trying FileMerge Operation in WSO2 EI 6.6.0 using FileConnector 2.0.24.
The problem here is that it is generating an output file with empty content.
API Code:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/mergefiles" name="FileMergeAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<log level="custom">
<property name="********FileMergeAPI" value="Called***********"/>
</log>
<property expression="json-eval($.source)" name="sourceDir" scope="default" type="STRING"/>
<property expression="json-eval($.destination)" name="destDir" scope="default" type="STRING"/>
<property expression="json-eval($.pattern)" name="pattern"/>
<property expression="fn:concat('file:///', $ctx:sourceDir)" name="sourceDir1" scope="default" type="STRING"/>
<property expression="fn:concat('file:///', $ctx:destDir)" name="destDir1" scope="default" type="STRING"/>
<fileconnector.mergeFiles>
<source>{$ctx:sourceDir1}</source>
<destination>{$ctx:destDir1}</destination>
<filePattern>{$ctx:pattern}</filePattern>
</fileconnector.mergeFiles>
<log level="full"/>
</inSequence>
<outSequence/>
<faultSequence>
<log level="custom">
<property name="text" value="An unexpected error occured"/>
<property expression="get-property('ERROR_MESSAGE')" name="message"/>
<property expression="get-property('ERROR_DETAIL')" name="errordetail"/>
</log>
<send description="Send Error Information"/>
</faultSequence>
</resource>
</api>
Input:
{
"source":"C://Development_Avecto//filemerge//input",
"destination":"C://Development_Avecto//filemerge//output//sample.csv",
"pattern":"//*.csv*"
}
wireLog:
[2022-05-02 13:13:13,417] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "POST /mergefiles HTTP/1.1[\r][\n]"
[2022-05-02 13:13:13,419] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Content-Type: application/json[\r][\n]"
[2022-05-02 13:13:13,422] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "User-Agent: PostmanRuntime/7.29.0[\r][\n]"
[2022-05-02 13:13:13,423] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Accept: */*[\r][\n]"
[2022-05-02 13:13:13,425] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Cache-Control: no-cache[\r][\n]"
[2022-05-02 13:13:13,426] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Postman-Token: dd7b1a25-b87e-4d64-b474-36b13159042a[\r][\n]"
[2022-05-02 13:13:13,427] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Host: 192.168.43.128:8280[\r][\n]"
[2022-05-02 13:13:13,428] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2022-05-02 13:13:13,429] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Connection: keep-alive[\r][\n]"
[2022-05-02 13:13:13,433] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "Content-Length: 164[\r][\n]"
[2022-05-02 13:13:13,436] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "[\r][\n]"
[2022-05-02 13:13:13,438] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "{[\r][\n]"
[2022-05-02 13:13:13,438] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> " "source":"C://Development_Avecto//filemerge//input",[\r][\n]"
[2022-05-02 13:13:13,439] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> " "destination":"C://Development_Avecto//filemerge//output//sample.csv",[\r][\n]"
[2022-05-02 13:13:13,440] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> " "pattern":"//*.csv*"[\r][\n]"
[2022-05-02 13:13:13,441] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 >> "}"
[2022-05-02 13:13:13,444] INFO {org.apache.synapse.mediators.builtin.LogMediator} - ********FileMergeAPI = Called***********
[2022-05-02 13:13:13,464] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: /mergefiles, MessageID: urn:uuid:90d67ec1-2a3f-4f13-8389-049a24abbdab, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><success>true</success></soapenv:Body></soapenv:Envelope>
[2022-05-02 13:13:13,478] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "HTTP/1.1 202 Accepted[\r][\n]"
[2022-05-02 13:13:13,479] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "Date: Mon, 02 May 2022 07:43:13 GMT[\r][\n]"
[2022-05-02 13:13:13,480] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "Transfer-Encoding: chunked[\r][\n]"
[2022-05-02 13:13:13,481] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "Connection: keep-alive[\r][\n]"
[2022-05-02 13:13:13,481] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "[\r][\n]"
[2022-05-02 13:13:13,483] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "0[\r][\n]"
[2022-05-02 13:13:13,483] DEBUG {org.apache.synapse.transport.http.wire} - HTTP-Listener I/O dispatcher-3 << "[\r][\n]"
if you noticed above wire log i got success response post mergefile operation like below
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><success>true</success></soapenv:Body></soapenv:Envelope>
I already looked this question which doesn't resolve my issue
File 1 content :
File 2 content:
PS: WSO2 EI 6.5.0 also tried the same. getting empty file
What is wrong with the above configuration?

Attachment Handling through WSO2 EI 6.1.1 in API

Use Case:
A REST API will be defined to handle the files sent by clients called (Postman REST Client) as attachment.
The files sent as attachment will be sent to Zoho Task Creation Endpoint in order to create task with Document.
Note: When i tried with postman directly by calling Zoho task Creation API, It creates task with Document.
Can anyone please let me know how to achieve this in API of WSO2 EI 6.1.1
Postman:
When i put log level="full" inside api,getting below log.
When i decode it via Online Tool which gives base64 decoded content like below.
API Code:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/uploadAttachment" name="AtatchmentAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<property name="messageType" scope="axis2" type="STRING" value="multipart/form-data"/>
<!-- <log level="full"/> -->
<log level="custom">
<property name="========UploadAttachment" value=" API Called=========="/>
<property name="========AttachmentName===" expression="get-property('transport', 'filename')"/>
</log>
<property expression="get-property('registry','gov:/ZohoConfig/ZohoAppConfigFile.txt')" name="accessToken" scope="default" type="STRING"/>
<!-- <log level="full"/> -->
<payloadFactory media-type="xml">
<format>
<ns:binary xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:binary>
</format>
<args>
<arg evaluator="xml" expression="//*[local-name()='binary']/text()"/>
</args>
</payloadFactory>
<script language="js">
<![CDATA[
var binaryNode =
mc.getEnvelope().getBody().getFirstElement().getFirstOMChild();
binaryNode.setBinary(true);
]]>
</script>
<property name="attachment_base64" expression="$body"/>
<log level="custom">
<property name="====attachment_base64====" expression="$body"></property>
</log>
<payloadFactory description="Form Response Payload" media-type="json">
<format>{"uploaddoc":$1}</format>
<args>
<arg evaluator="xml" expression="$ctx:attachment_base64"/>
</args>
</payloadFactory>
<log level="custom">
<property name="====uploaddoc_Payload====" expression="$body"></property>
</log>
<!-- <log level="full"/> -->
<property name="transport.vfs.ReplyFileName" value="ZohoTestFile.txt" scope="transport"/>
<property name="transport.vfs.Streaming" value="true" scope="transport"/>
<property name="ClientApiNonBlocking" action="remove" scope="axis2"/>
<property name="messageType" scope="axis2" value="application/binary"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<header expression="fn:concat('Bearer ', '1000.CCCCCCCCCC.XXXXXXXXXXXXXXXXXX')" name="Authorization" scope="transport"/>
<call>
<endpoint>
<address uri="https://projectsapi.zoho.com/restapi/portal/36249112/projects/685798000000976352/tasks/685798000011774999/attachments/"/>
</endpoint>
</call>
<log>
<property expression="json-eval($.)" name="==API Response======"/>
</log>
<!-- <payloadFactory description="Form Response Payload" media-type="json">
<format>{"recipients":"Regularrrrrrrrrrrrr"}</format>
<args/>
</payloadFactory>
<log>
<property expression="json-eval($.)" name="==Final- CampaignBuilder_JsonRequest_ForCreation======"/>
</log> -->
<respond/>
<!-- <property expression="String(//mediate/file/#filename)" name="filename" scope="default" type="STRING"/> -->
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
API Response:
{
"error": {
"code": 6831,
"message": "Input Parameter Missing"
}
}
Reason: need to pass attachment to the param called "uploaddoc" when calling Zoho API. here i don't know how to set attachment to that field
Wire Logs:
3:04:42,565] [] INFO - APIDeployer API named 'AtatchmentAPI' has been deployed from file : D:\ServerSetup 6.1.1\wso2ei-6.1.1\wso2\tmp\carbonapps\-1234\1602833682469Att
-CAR_1.0.0.car\AtatchmentAPI_1.0.0\AtatchmentAPI-1.0.0.xml
3:04:42,565] [] INFO - ApplicationManager Successfully Deployed Carbon Application : AttachmentUpload-CAR_1.0.0 {super-tenant}
3:05:04,362] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "POST /uploadAttachment HTTP/1.1[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "User-Agent: PostmanRuntime/7.26.5[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Accept: */*[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Postman-Token: 21c46ad2-19fc-46a6-aea8-8113ac70817e[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Host: localhost:8280[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
3:05:04,364] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Connection: keep-alive[\r][\n]"
3:05:04,364] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Type: multipart/form-data; boundary=--------------------------623932778277436708655778[\r][\n]"
3:05:04,364] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Cookie: bf42f62d55=64dc75f94d2bd72d94493d263847c08c[\r][\n]"
3:05:04,364] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Length: 376[\r][\n]"
3:05:04,365] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "[\r][\n]"
3:05:04,365] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "----------------------------623932778277436708655778[\r][\n]"
3:05:04,365] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Disposition: form-data; name="uploaddoc"; filename="ZohoAttachment.txt"[\r][\n]"
3:05:04,365] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Type: text/plain[\r][\n]"
3:05:04,366] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "[\r][\n]"
3:05:04,370] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Hi,[\r][\n]"
3:05:04,371] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "This is zoho Attachment task[\r][\n]"
3:05:04,371] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "----------------------------623932778277436708655778[\r][\n]"
3:05:04,371] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Disposition: form-data; name="name"[\r][\n]"
3:05:04,373] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "[\r][\n]"
3:05:04,373] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "TaskAttachment Demo[\r][\n]"
3:05:04,373] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "----------------------------623932778277436708655778--[\r][\n]"
3:05:04,373] [] INFO - LogMediator ========UploadAttachment = API Called==========, ========AttachmentName=== = null
3:05:04,398] [] INFO - LogMediator ====attachment_base64==== = <soapenv:Body xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><ns:binary xmlns:ns="http://ws.apa
ns/ns/payload">LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ1cGxvYWRkb2MiOyBmaWxlbmFtZT0iW
1lbnQudHh0Ig0KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluDQoNCkhpLA0KVGhpcyBpcyB6b2hvIEF0dGFjaG1lbnQgdGFzaw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA
EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJuYW1lIg0KDQpUYXNrQXR0YWNobWVudCBEZW1vDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tNjIzOTMyNzc4Mjc3NDM2NzA4NjU1Nzc4LS0NCg==</ns:binary
dy>
3:05:04,402] [] INFO - LogMediator ====uploaddoc_Payload==== = <soapenv:Body xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><uploaddoc xmlns="http://ws.apache
se">LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ1cGxvYWRkb2MiOyBmaWxlbmFtZT0iWm9ob0F0dGFj
g0KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluDQoNCkhpLA0KVGhpcyBpcyB6b2hvIEF0dGFjaG1lbnQgdGFzaw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA0KQ29udGVud
lvbjogZm9ybS1kYXRhOyBuYW1lPSJuYW1lIg0KDQpUYXNrQXR0YWNobWVudCBEZW1vDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tNjIzOTMyNzc4Mjc3NDM2NzA4NjU1Nzc4LS0NCg==</uploaddoc></soapenv:
3:05:05,124] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "POST /restapi/portal/36249008/projects/685798000009576352/tasks/685798000011774013/attachments/ HTTP/1.1[
3:05:05,126] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Authorization: Bearer 1000.9df1f22e7d16ba95f0553af9855d40b5.f81f2af95682c8b398d0bb4939190d10[\r][\n]"
3:05:05,127] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Cookie: bf42f62d55=64dc75f94d2bd72d94493d263847c08c[\r][\n]"
3:05:05,127] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "transport.vfs.Streaming: true[\r][\n]"
3:05:05,127] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Accept: */*[\r][\n]"
3:05:05,128] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Postman-Token: 21c46ad2-19fc-46a6-aea8-8113ac70817e[\r][\n]"
3:05:05,128] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Accept-Encoding: gzip, deflate, br[\r][\n]"
3:05:05,128] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "transport.vfs.ReplyFileName: ZohoTestFile.txt[\r][\n]"
3:05:05,129] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Content-Type: application/binary[\r][\n]"
3:05:05,129] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Transfer-Encoding: chunked[\r][\n]"
3:05:05,129] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Host: projectsapi.zoho.com[\r][\n]"
3:05:05,130] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Connection: Keep-Alive[\r][\n]"
3:05:05,130] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
3:05:05,130] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "[\r][\n]"
3:05:05,131] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "237[\r][\n]"
3:05:05,131] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "<uploaddoc xmlns="http://ws.apache.org/ns/synapse">LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3Nz
3OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ1cGxvYWRkb2MiOyBmaWxlbmFtZT0iWm9ob0F0dGFjaG1lbnQudHh0Ig0KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluDQoNCkhpLA0KVGhpcyBpcyB
aG1lbnQgdGFzaw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJuYW1lIg0KDQpUYXNrQXR0YWNobWVu
S0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tNjIzOTMyNzc4Mjc3NDM2NzA4NjU1Nzc4LS0NCg==</uploaddoc>[\r][\n]"
3:05:05,134] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "0[\r][\n]"
3:05:05,135] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "[\r][\n]"
3:05:05,905] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "HTTP/1.1 400 [\r][\n]"
3:05:05,906] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Server: ZGS[\r][\n]"
3:05:05,906] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Date: Fri, 16 Oct 2020 07:35:06 GMT[\r][\n]"
3:05:05,906] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Type: application/json;charset=utf-8[\r][\n]"
3:05:05,906] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Length: 60[\r][\n]"
3:05:05,907] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Connection: keep-alive[\r][\n]"
3:05:05,907] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Content-Type-Options: nosniff[\r][\n]"
3:05:05,907] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-XSS-Protection: 1[\r][\n]"
3:05:05,908] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: zpct=24a027ad-3cd2-4edf-b641-b792d3ffede8;path=/;SameSite=None;Secure;priority=high[\r][\n]"
3:05:05,908] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: _zcsr_tmp=24a027ad-3cd2-4edf-b641-b792d3ffede8;path=/;SameSite=Strict;Secure;priority=high[\r
3:05:05,908] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Pragma: no-cache[\r][\n]"
3:05:05,909] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Cache-Control: no-cache[\r][\n]"
3:05:05,909] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
3:05:05,909] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: JSESSIONID=9FD064E43DACD49060E958A34C2E0325; Path=/; Secure[\r][\n]"
3:05:05,909] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Frame-Options: SAMEORIGIN[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-UA-Compatible: IE=9, IE=10[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Disposition: attachment; filename=response.txt;[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Download-Options: noopen[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "{"error":{"code":6831,"message":"Input Parameter Missing"}}[\n]"
3:05:05,921] [] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:49cdf6b1-0ac6-4728-bc92-f8658b4a88
: request, ==API Response====== = {"error":{"code":6831,"message":"Input Parameter Missing"}}
3:05:05,925] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "HTTP/1.1 400 [\r][\n]"
3:05:05,925] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-Frame-Options: SAMEORIGIN[\r][\n]"
3:05:05,925] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-UA-Compatible: IE=9, IE=10[\r][\n]"
3:05:05,926] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Cache-Control: no-cache[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-Content-Type-Options: nosniff[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Content-Disposition: attachment; filename=response.txt;[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-Download-Options: noopen[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Set-Cookie: JSESSIONID=9FD064E43DACD49060E958A34C2E0325; Path=/; Secure[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Set-Cookie: _zcsr_tmp=24a027ad-3cd2-4edf-b641-b792d3ffede8;path=/;SameSite=Strict;Secure;priority=high[\
3:05:05,928] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Set-Cookie: zpct=24a027ad-3cd2-4edf-b641-b792d3ffede8;path=/;SameSite=None;Secure;priority=high[\r][\n]"
3:05:05,928] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
3:05:05,929] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Pragma: no-cache[\r][\n]"
3:05:05,929] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-XSS-Protection: 1[\r][\n]"
3:05:05,929] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Content-Type: application/json;charset=utf-8[\r][\n]"
3:05:05,930] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Date: Fri, 16 Oct 2020 07:35:05 GMT[\r][\n]"
3:05:05,930] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Transfer-Encoding: chunked[\r][\n]"
3:05:05,930] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Connection: Close[\r][\n]"
3:05:05,930] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "[\r][\n]"
3:05:05,931] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "3c[\r][\n]"
3:05:05,931] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "{"error":{"code":6831,"message":"Input Parameter Missing"}}[\n]"
3:05:05,931] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "[\r][\n]"
3:05:05,931] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "0[\r][\n]"
3:05:05,932] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "[\r][\n]"
Can Anyone please give me a solution for this?
Looking at your code you are not doing anything with the incoming payload. so why are you trying to mediate the payload? just pass through it.
Mock zoho api (use any simple python, pip install web server) and dump request came from ESB and see what is missing in request. Some of the header most probably missing, Content-Disposition Content-Type
API states "name" parameter is mandatory.

WSO2 ESB - clone and aggregate mediator not sending back response

I have a strange problem while using clone - aggregate mediator. I put log in the onComplete and saw the data, but that data never sending back to the client.
Here is the code I used.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/OneVinmec" name="OneVinmec" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/getPID?*">
...
<outSequence>
<property name="info" scope="default">
<ns:Information xmlns:ns="http://wso2.com"/>
</property>
<aggregate id="getPID">
<completeCondition timeout="10">
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete enclosingElementProperty="info" expression="//*[local-name() = 'DSBenhNhan']">
<log description="DSBenhNhan" level="custom">
<property expression="//*[local-name() = 'DSBenhNhan']" name="DSBenhNhan"/>
</log>
<send/>
</onComplete>
</aggregate>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
This is the log I got from console, as you can see, there is log INFO - LogMediator, but after that, the response is not sending back.
Edit: After remove the content-encoding header, the Log now show this
[2020-02-12 17:30:16,052] INFO - LogMediator DSBenhNhan = <DSBenhNhan xmlns="http://ws.wso2.org/dataservice/getPID"><BenhNhan><Source_System>OH</Source_System><PID>200380141</PID></BenhNhan></DSBenhNhan><DSBenhNhan xmlns="http://ws.wso2.org/dataservice/getPID"><BenhNhan><Source_System>eHOS</Source_System><PID>19006032</PID></BenhNhan><BenhNhan><Source_System>eHOS</Source_System><PID>19086413</PID></BenhNhan></DSBenhNhan>
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "HTTP/1.1 200 OK[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-Frame-Options: DENY[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "0[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-Content-Type-Options: nosniff[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Vary: Accept-Encoding[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-XSS-Protection: 1; mode=block[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Content-Type: application/xml;charset=UTF-8[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Date: Wed, 12 Feb 2020 10:30:16 GMT[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Transfer-Encoding: chunked[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "1aa[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "<ns:Information xmlns:ns="http://wso2.com"><DSBenhNhan xmlns="http://ws.wso2.org/dataservice/getPID"><BenhNhan><Source_System>OH</Source_System><PID>200380141</PID></BenhNhan></DSBenhNhan><DSBenhNhan xmlns="http://ws.wso2.org/dataservice/getPID"><BenhNhan><Source_System>eHOS</Source_System><PID>19006032</PID></BenhNhan><BenhNhan><Source_System>eHOS</Source_System><PID>19086413</PID></BenhNhan></DSBenhNhan></ns:Information>[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "0[\r][\n]"
[2020-02-12 17:30:16,052] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "[\r][\n]"
Appreciate your help!
According to [2020-02-12 15:59:27,259] DEBUG - wire HTTP-Listener I/O dispatcher-4 << "Content-Encoding: gzip[\r][\n], it seems the content-encoding is in gzip format. Please skip that header from the client when invoking the API.

WSO2 FHIR Connector: error on handling FHIR server response after create resource

I have send to the server a request for create operation. After the creation of the resource the server response is not returned to the client due to the follows error: Axis2Sender Unexpected error during sending message out
The server response is HTTP/1.1 201 Created
[2017-05-11 09:44:06,745] [] DEBUG - LoggingNHttpClientConnection http-outgoing-8: Consume input
[2017-05-11 09:44:06,746] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "HTTP/1.1 201 Created[\r][\n]"
[2017-05-11 09:44:06,747] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Cache-Control: private[\r][\n]"
[2017-05-11 09:44:06,747] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Length: 1155[\r][\n]"
[2017-05-11 09:44:06,748] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Type: application/fhir+json; charset=utf-8[\r][\n]"
[2017-05-11 09:44:06,749] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Location: https://sqlonfhir-stu3.azurewebsites.net/fhir/Patient/d1ecfb4f816d
466ab94479c662b1b448/_history/1[\r][\n]"
[2017-05-11 09:44:06,749] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Last-Modified: Thu, 11 May 2017 07:44:17 GMT[\r][\n]"
[2017-05-11 09:44:06,750] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "ETag: W/"1"[\r][\n]"
[2017-05-11 09:44:06,750] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Location: https://sqlonfhir-stu3.azurewebsites.net/fhir/Patient/d1ecfb4f816d466ab944
79c662b1b448/_history/1[\r][\n]"
[2017-05-11 09:44:06,751] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Server: Microsoft-IIS/8.0[\r][\n]"
[2017-05-11 09:44:06,751] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-AspNet-Version: 4.0.30319[\r][\n]"
[2017-05-11 09:44:06,751] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Request-Context: appId=cid-v1:db89bf18-68ce-4c00-a208-3700054b56ad[\r][\n]"
[2017-05-11 09:44:06,752] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Powered-By: ASP.NET[\r][\n]"
[2017-05-11 09:44:06,752] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: ARRAffinity=db0274c056695d20e92cbf53a580c5fe334eaf55b913573afc6435767938
c334;Path=/;Domain=sqlonfhir-stu3.azurewebsites.net[\r][\n]"
[2017-05-11 09:44:06,753] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Date: Thu, 11 May 2017 07:44:16 GMT[\r][\n]"
[2017-05-11 09:44:06,753] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
[2017-05-11 09:44:06,754] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "{"resourceType":"Patient","id":"d1ecfb4f816d466ab94479c662b1b448","meta":{"versionId
":"1"...
but on handling the response WSO2 throws the follows error:
[2017-05-11 09:44:06,763] [] DEBUG - headers http-outgoing-8 << Date: Thu, 11 May 2017 07:44:16 GMT
[2017-05-11 09:44:06,764] [] DEBUG - TargetHandler http-outgoing-8: HTTP/1.1 201 Created
[2017-05-11 09:44:06,764] [] DEBUG - TargetHandler http-outgoing-8: Input ready
[2017-05-11 09:44:06,765] [] DEBUG - TargetHandler http-outgoing-8: Content decoder [content length: 1155; pos: 1155; completed: true]
[2017-05-11 09:44:06,769] [] DEBUG - RelayUtils Content Type is application/fhir+json; charset=utf-8
[2017-05-11 09:44:06,771] [] ERROR - Axis2Sender Unexpected error during sending message out
java.lang.NullPointerException
at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer.java:211)
at org.apache.coyote.http11.InternalNioOutputBuffer.commit(InternalNioOutputBuffer.java:203)
at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:776)
at org.apache.coyote.Response.action(Response.java:174)
at org.apache.coyote.Response.sendHeaders(Response.java:348)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:352)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:311)
at org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:108)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.sendUsingOutputStream(PassThroughHttpSender.java:308)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:271)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.send(DynamicAxisOperation.java:185)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:167)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:595)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:83)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:548)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:118)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:281)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:775)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:262)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I have added in EI_HOME/conf/axis2.xml
<messageFormatter contentType="application/fhir+json" class="org.wso2.carbon.integrator.core.json.JsonStreamFormatter"/>
and
<messageBuilder contentType="application/fhir+json" class="org.wso2.carbon.integrator.core.json.JsonStreamBuilder"/>
but without success.
Without add messageBuilder and messageFormatter for "application/fhir+json" I have the follows error:
[2017-05-11 11:29:18,247] [] DEBUG - TransportUtils Could not find a Builder for type (application/fhir+json). Using SOAP.
[2017-05-11 11:29:18,257] [] INFO - BuilderUtil OMException in getSOAPBuilder
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '<'
at [row,col {unknown-source}]: [2,1]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)...
Can you try with following builder and formatter?
<messageFormatter contentType="application/fhir+json" class="org.apache.synapse.commons.json.JsonStreamFormatter"/>
<messageBuilder contentType="application/fhir+json" class="org.apache.synapse.commons.json.JsonStreamBuilder"/>