SMS Gateway setup

Jim Bafosa year ago

I need to setup sms notification using sms provider easysms. The endpoint documentation is here
Easy SMS Send API

In mine config I have

<entry key='notificator.types'>sms,web,mail</entry>
<entry key='sms.http.url'>https://easysms.gr/api/sms/send</entry>
<entry key='sms.http.authorization'>XXXXXXX</entry>
<entry key='sms.http.template'>
    {
        "key":"XXXXXXXXXXX",
        "to": "{phone}",
        "message": "{message}"
    }
</entry>

But in my tests no sms is sent. Any suggestions?

EDIT: Maybe irrelevant but a python working code is bellow

import requests

url = "https://easysms.gr/api/sms/send"

payload = {'key': 'XXXXXXXXX',
'text': 'Your message',
'from': 'From Name',
'to': 'XXXXXXXXXXX',
'type': 'json',
'ucs': 'true'}
files=[]
headers = {}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
Anton Tananaeva year ago

I'm very confused. Why is the payload different from the working example?

Jim Bafosa year ago

Sorry about that. Copy paste problems.
My current config is:

<entry key='sms.http.url'>https://easysms.gr/api/sms/send</entry>
<entry key='sms.http.authorization'>XXXXX</entry>
<entry key='sms.http.template'>
    {
        "key":"XXXXXXXX",
        "text": "{message}",
        "from": "YYYYY",
        "to": "{phone}",
        "type": "json",
        "ucs": "true"
    }
</entry>

Is it something wrong with that? Did I misunderstood something?

Anton Tananaeva year ago

I don't see anything wrong. Make sure that the phone number is in the right format that the service expects.

Jim Bafosa year ago

Thank you very much Anton but the phone is in the correct format. Also if that was the case then the provider would have charged me, but did not. Are there any steps to trace the problem? Logs maybe

Anton Tananaeva year ago

What response do you get when you test it?

Jim Bafosa year ago

Nothing

Anton Tananaeva year ago

If nothing, it means your provider accepted the API call successfully. So you need to talk to them.

Jim Bafosa year ago

Ok I will. Thanks

Jim Bafosa year ago

Hi Anton.I have contacted the provider. They say that they don’t see something on their logs. Is there anything else that we can do?

Anton Tananaeva year ago

I don't think so.

Jim Bafosa year ago

I think I narrow the problem. The API wants the body to be as form data, but my payload is json. How to change the above sms.http.template to be as form-data?

Anton Tananaeva year ago

This statement directly contradicts the original information you provided. Your "python working code" sends JSON.

Jim Bafosa year ago

Yes I know that. Strange but python code is working. Also it's an assumption that api needs the body as form data. I have no access to that source code. I have created a temporary "in the middle API" to act as a negotiator between traccar and easysms and I notice that the api is working fine if I pass form data but fails in json. Can you provide info on how to change the payload to form-data and I will come back if I have any success

Anton Tananaeva year ago