布尔类型属性在WSO2 EI 6.1.1中不起作用



我正在将BOOLEAN类型属性值(请参阅代码中的:delete_all_contacts属性(传递到在WSO2 EI 6.1.1中不起作用的端点url。得到类似于"strong>"的错误;delete_all_contacts'是布尔型必需参数"。我认为它被视为";字符串";类型,即使属性类型为BOOLEAN。请有人帮我解决这个问题吗?

参考链接:https://sendgrid.api-docs.io/v3.0/contacts/delete-contacts

API代码:

<api context="/contactapi" name="ContactAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/deletecontact?*">
<inSequence>

<log level="custom">
<property name="===Delete contacts " value=" API Called===="/>
<property expression="get-property('query.param.delete_all_contacts')/" name="===query.param.delete_all_contacts==="/>
<property expression="get-property('query.param.ids')/" name="===query.param.ids==="/>
</log>

<property  name="delete_all_contacts" expression="get-property('query.param.delete_all_contacts')" scope="default" type="BOOLEAN"/>
<property expression="get-property('query.param.ids')" name="ids" scope="default" type="STRING"/>
<property expression="get-property('Sendgrid-Config')" name="SendgridConfig" scope="default" type="OM"/>
<property description="apiKey" expression="$ctx:SendgridConfig//*[local-name()='apiKey']" name="apiKey" scope="default" type="STRING"/>
<header expression="fn:concat('Bearer ', get-property('apiKey'))" name="Authorization" scope="transport"/>
<filter regex="true" source="boolean(get-property('delete_all_contacts'))">
<then>

<header expression="fn:concat('https://api.sendgrid.com/v3/marketing/contacts','?delete_all_contacts=',get-property('delete_all_contacts'))" name="To" scope="default"/>
<log level="custom">
<property expression="get-property('To')" name="===To==="/>
</log>
</then>
<else>
<header expression="fn:concat('https://api.sendgrid.com/v3/marketing/contacts','?ids=',get-property('ids'))" name="To" scope="default"/>
<log level="custom">
<property expression="get-property('To')" name="===To==="/>
</log>
</else>
</filter>
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="DELETE"/>
<call>
<endpoint>
<default/>
</endpoint>
</call>
<respond/>
</inSequence>
<outSequence/>
<faultSequence>
<log level="custom">
<property name="===faultSequence" value="Called=="/>
<property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE"/>
</log>
</faultSequence>
</resource>
</api>

API详细信息:

URL:http://localhost:8280/contactapi/deletecontact?delete_all_contacts=true

方法:删除

错误响应:

{"message":"'delete_all_contacts' is  boolean required param","parameter":"delete_all_contacts"}

我尝试了API的精简版本,它似乎正在运行。

<api xmlns="http://ws.apache.org/ns/synapse" name="ContactAPI" context="/contactapi">
<resource methods="POST" uri-template="/deletecontact?*">
<inSequence>
<log level="custom">
<property name="===Delete contacts " value=" API Called===="/>
<property name="===query.param.delete_all_contacts===" expression="get-property('query.param.delete_all_contacts')/"/>
</log>
<property name="delete_all_contacts" expression="get-property('query.param.delete_all_contacts')" scope="default" type="BOOLEAN"/>
<filter source="boolean(get-property('delete_all_contacts'))" regex="true">
<then>
<log level="custom">
<property name="===Inside===" value="Then"/>
</log>
</then>
<else>
<log level="custom">
<property name="===Inside===" value="Else"/>
</log>
</else>
</filter>
<respond/>
</inSequence>
<outSequence/>
<faultSequence>
<log level="custom">
<property name="===faultSequence" value="Called=="/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
</faultSequence>
</resource>
</api>

但是,我注意到您已经将资源方法定义为POST,并发送了一个DELETE请求。也许这导致了一些问题。

最新更新