A Restful Endpoint used in WSO2 not receiving any request payload

235 Views Asked by At

Am trying to call two restful endpoints in WSO2. The response from the first endpoint is used to build a json payload to send as a post request to the second endpoint. The issue is that no payload is seen by the second endpoint, hence error message of "The JSON syntax provided in the body of the request is invalid: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 54" is displayed.

When I enabled wirelogs, i discovered that a post request is send to the second endpoint but no payload. But what surprises me is that the payload is not empty when I logged it.

Please i will be grateful if you can help me out.

Please find below my model snippet

<?xml version="1.0" encoding="UTF-8"?>
<api context="/openAccount" name="AccountCreation" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST">
        <inSequence>
            <log/>
            <header name="Authorization" scope="transport" value="Basic bWlmb3M6cGFzc3dvcmQ="/>
            <header name="Content-Type" scope="transport" value="text/plain"/>
            <header name="Fineract-Platform-TenantId" scope="transport" value="default"/>
            <property expression="get-property('SYSTEM_DATE', 'dd MMMM yyyy')" name="todayDate" scope="default" type="STRING"/>
            <payloadFactory media-type="json">
                <format>
            {
                                "firstname" : "$1",
                                 "lastname" : "$2",
                                 "externalId":"$3",
                                 "dateFormat":"$4",
                                 "locale":"$5",
                                 "officeId":"$6",
                                 "mobileNo":"$7",
                                 "clientTypeId":"$8",
                                 "clientClassificationId":"$9",
                                 "legalFormId":"$10",
                                 "dateOfBirth":"$11",
                                 "genderId":"$12",
                                 "submittedOnDate":"$13",
                                 "active":"true",
                                 "activationDate":"$14"

                         }
            </format>
                <args>
                    <arg evaluator="json" expression="$.firstname"/>
                    <arg evaluator="json" expression="$.lastname"/>
                    <arg evaluator="json" expression="$.externalId"/>
                    <arg evaluator="json" expression="$.dateFormat"/>
                    <arg evaluator="json" expression="$.locale"/>
                    <arg evaluator="json" expression="$.officeId"/>
                    <arg evaluator="json" expression="$.motherMaidenName"/>
                    <arg evaluator="json" expression="$.accountPurpose"/>
                    <arg evaluator="json" expression="$.maritalStatus"/>
                    <arg evaluator="json" expression="$.legalFormId"/>
                    <arg evaluator="json" expression="$.dateOfBirth"/>
                    <arg evaluator="json" expression="$.genderId"/>
                    <arg evaluator="json" expression="$.submittedOnDate"/>
                    <arg evaluator="xml" expression="get-property('todayDate')"/>
                </args>
            </payloadFactory>
            <property name="STATE" scope="default" type="STRING" value="CUSTOMER_CREATION"/>
            <property name="FORCE_HTTP_1.0" scope="axis2" type="STRING" value="true"/>
            <property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
            <log>
                <property expression="json-eval($.)" name="customer-payload"/>
            </log>
            <send>
                <endpoint key="client-create-endpoint"/>
            </send>
        </inSequence>
        <outSequence>
            <switch source="get-property('STATE')">
                <case regex="CUSTOMER_CREATION">
                    <log>
                        <property expression="json-eval($.)" name="customer-response-payload"/>
                    </log>
                    <header name="Authorization" scope="transport" value="Basic bWlmb3M6cGFzc3dvcmQ="/>
                    <header name="Content-Type" scope="transport" value="text/plain"/>
                    <header name="Fineract-Platform-TenantId" scope="transport" value="default"/>
                    <payloadFactory media-type="json">
                        <format>{"productId":"1","locale":"en","dateFormat":"dd MMMM yyyy","clientId":"$1"}
           </format>
        <args>
            <arg evaluator="json" expression="$.clientId"/>
        </args>
                    </payloadFactory>
                    <log level="full">
                        <property expression="json-eval($.)" name="savingsaccount-request-payload"/>
                    </log>
                    <property name="STATE" scope="default" type="STRING" value="ACCOUNT_CREATION"/>
                    <property name="FORCE_HTTP_1.0" scope="axis2" type="STRING" value="true"/>
                    <property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>


                    <send>
                        <endpoint key="account-create-endpoint"/>
                    </send>
                </case>
                <case regex="ACCOUNT_CREATION">
                    <log level="full">
                        <property expression="json-eval($.)" name="savingsaccount-response-payload"/>
                    </log>
                    <send/>
                </case>
                <default/>
            </switch>
        </outSequence>
        <faultSequence/>
    </resource>
</api>
0

There are 0 best solutions below