在Mule4中,在http url中,我如何传递一个具有相同键但有多个值的查询参数



我试过这样的方法,但不起作用-

http://training-american-ws.cloudhub.io/api/flights?destination=SFO&destination=CLE

当您创建一个对象作为查询参数时,默认情况下DataWeave使用不允许每个键有多个值的Java映射来实现它。看起来显式地将输出设置为JSON允许它:

<flow name="test-http-queryParams-multivalued-key"  >
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/multikey"/>
<set-variable value='#[output application/json --- {"key1":"aaa","key1":"bbb","key1":"ccc","key2":"ddd"}]' doc:name="Set Variable" variableName="myQueryParams"/>
<logger level="INFO" doc:name="Logger" message="values #[vars.values]"/>
<http:request method="GET" doc:name="Request" config-ref="HTTP_Request_configuration" path="/backend" >
<http:query-params ><![CDATA[#[vars.myQueryParams]]]></http:query-params>
</http:request>
</flow>

最新更新