admin管理员组

文章数量:1301534

I am working with WSO2 API Manager / WSO2 EI and trying to fetch appointment data from two different APIs (Vodafone and TalkTalk). The Vodafone API returns a JSON array, while the TalkTalk API returns a JSON array. The first placed sequence mediator fetches and appends correctly but second gives me error

When I send the response from my API, I get the following error:

<resource methods="POST" uri-template="/get-available-appointments">
<inSequence>
<log level="custom">
<property name="Step" value="Starting get-available appointments API"/>
</log>
<sequence key="GetVodafoneAvailableAppointmentsSequence"/>
<sequence key="GetAvailableAppointmentsSequence"/>
<payloadFactory media-type="json">
<format>
{
"VodafoneAppointmentResponse": $1, 
"TalkTalkAppointmentResponse": [$2]
}
</format>
<args>
<arg evaluator="xml" expression="get-property('VodafoneAvailableAppointmentsResponse')"/>
<arg evaluator="xml" expression="get-property('AvailableAppointmentsResponse')"/>
</args>
</payloadFactory>
<respond/>
</inSequence>
</resource>

The TalkTalkAppointmentResponse is being treated as an array, but the API expects a JSON object.

How can I properly structure the TalkTalk API response so that it is accepted as a JSON object instead of an array?

<payloadFactory media-type="json">
<format>
{
"VodafoneAppointmentResponse": $1, 
"TalkTalkAppointmentResponse": {
"appointments": $2
}
}
</format>
<args>
<arg evaluator="xml" expression="get-    property('VodafoneAvailableAppointmentsResponse')"/>
<arg evaluator="xml" expression="get-property('AvailableAppointmentsResponse')"/>
</args>
</payloadFactory>

本文标签: