Hello!
We have been doing some tests lately regarding the Mobile configuration and if you are using Clickatell as your SMS Gateway you might have found out that it is currently not working while sending SMS.
This will get fixed in the near future, however, if you are suffering from this and you still need to send SMS out of your DHIS2 server here is the work around that involves modifying something on your Gateway settings via the API.
- Access with an admin account to your DHIS 2 server and go to mobile configuration, add a new Generic gateway (no Clickatell but generic) with the following values
Note:
- Gateway name can be whatever you want
- Message (content), recipient (to) and URL (https://platform.clickatell.com/messages/http/send) Template must be exactly like shown above
- add a new value called apiKey and add the apiKey that you get from Clicaktell
Save and back!
-
Now we mark this gateway as default by clicking on the icon
-
That’s all the things that we need to do by using the DHIS 2 UI, now comes the API calls.
-
Get the list of gateways from your server by performing the API call https://example.org/api/gateways which will display one or two gateways like here:
There you will need to get the UID of the gateway that you have created, in this case: AktsSssO1M
- Perform an API call to only that gateway https://example.org/api/gateways/AktsSssO1M which will display the JSON values
This is the text that you need to copy and modify. Here I have already fixed but what it is important is to make sure that the useGet is set to true (in your server will say false )
- Perform an update on the gateway via an API call with your program of choice, I am doing it here with CURL in my terminal
jaime@WeatherLight:~$ curl -X PUT -H “Content-Type: application/json” -u admin:district “http://example.org/api/gateways/AktsSssO1M” -d ‘{“uid”:“AktsSssO1M”,“name”:“Clickatell as generic”,“urlTemplate”:"https://platform.clickatell.com/messages/http/send",“messageParameter”:“content”,“recipientParameter”:“to”,“useGet”:true,“parameters”:[{“header”:false,“key”:“apiKey”,“value”:" XXXXXXXXXXXXXXXXXXXXXXX ",“classified”:false}],“isDefault”:true}’
Note, if you get a response saying something like “a default gateway already exists” modify the last key/value to “isDefault”:false and then via the DHIS 2 Mobile configuration make it default gateway.
Once this is done you can go to the Send SMS in the Mobile configuration and test it
And on your logs you should see the following:
- INFO 2020-04-02 10:15:50,997 [Level: INFO, category: SMS_SEND, time: Thu Apr 02 10:15:50 GMT 2020, message: Sending SMS] (InMemoryNotifier.java [taskScheduler-20])
- INFO 2020-04-02 10:15:51,000 Sending SMS to [34659138936] (SmsMessageSender.java [taskScheduler-20])
- INFO 2020-04-02 10:15:51,257 SMS sent (SmsMessageSender.java [taskScheduler-20])
- INFO 2020-04-02 10:15:51,258 [Level: INFO, category: SMS_SEND, time: Thu Apr 02 10:15:51 GMT 2020, message: Message sending successful] (InMemoryNotifier.java [taskScheduler-20])
- INFO 2020-04-02 10:15:51,259 ‘system-process’ create org.hisp.dhis.sms.outbound.OutboundSms (AuditLogUtil.java [taskScheduler-20])