Open mefarazath opened 4 years ago
Seems like NEXMO has request body to application/x-www-form-urlencoded
. If we change the publisher as follows it will work.
<?xml version="1.0" encoding="UTF-8"?>
<eventPublisher name="HTTPOutputEventAdapter" processing="enable"
statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="id_gov_sms_notify_stream" version="1.0.0"/>
<mapping customMapping="enable" type="text">
<inline><![CDATA[api_key=1234567&api_secret=123456789hfdsert&from=NEXMO&to={{mobile}}&text={{body}}]]></inline>
</mapping>
<to eventAdapterType="http">
<property name="http.client.method">httpPost</property>
<property name="http.headers">Content-Type:application/x-www-form-urlencoded</property>
<property name="http.url">https://rest.nexmo.com/sms/json</property>
</to>
</eventPublisher>
More information can be found at https://developer.nexmo.com/api/sms
In order to user TWILO, we can use the following publisher.
<?xml version="1.0" encoding="UTF-8"?>
<eventPublisher name="HTTPOutputEventAdapter" processing="enable"
statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="id_gov_sms_notify_stream" version="1.0.0"/>
<mapping customMapping="enable" type="text">
<inline><![CDATA[Body={{body}}&From=+12058589069&To={{mobile}}]]></inline>
</mapping>
<to eventAdapterType="http">
<property name="http.client.method">httpPost</property>
<property name="http.headers">Content-Type:application/x-www-form-urlencoded,Authorization:Basic <basic_auth_header_value></property>
<property name="http.url">https://api.twilio.com/2010-04-01/Accounts/AC0af3fhbsdf372749224ebd57b8350cf/Messages.json</property>
</to>
</eventPublisher>
In a publisher, if we want to specify the content-type, we can add it as a header. If we have multiple headers, we can add them in a comma(,
) separated manner.
<property name="http.headers">Content-Type:application/x-www-form-urlencoded,Authorization:Basic QUMwYWYzZjg2ZTMwMmQ2Y2QzNDFlOGViZDU3YjgzNTBjZjplMTc3Y2YzMzNjYjY2MTMwODlhZGRjZDU4N2UwYTJlMA==</property>
For content-type application/x-www-form-urlencoded
, mapping type to text
. If the endpoint expects a json set it as json
.
<mapping customMapping="enable" type="text">
We cannot add any query params to property tags. Instead, if we have any query params, we should mention them within mapping
tags.
<mapping customMapping="enable" type="text">
<inline><![CDATA[Body={{body}}&From=+12058589069&To={{mobile}}]]></inline>
</mapping>
Is your suggestion related to an experience ? Please describe. Seems like Nexmo and other providers have API changes and we need to include instructions on how we can fix the publisher to adhere to the required format.