Variable 'phone' has no value [SMS Notification]

CrossFire101004 years ago

Hi there, I hope you are having a great day!
I been researching on this forum and on google about this issue, but I don't seem to have any luck on getting it figured out.
I am trying to setup notifications via whatsapp and I am using this API. Which I tested and it works but I cant get it working on traccar
whatsapp-node-api

This is the default.xml part

<entry key='notificator.types'>web,mail,firebase,sms</entry>
<entry key='notificator.sms.manager.class'>org.traccar.sms.HttpSmsClient</entry>
<entry key='sms.http.url'>http://IPADDRESS:PORT/chat/sendmessage/{phone} -X POST</entry>
<entry key='sms.http.template'>
{
 "to": "{phone}",
 "message": "{message}"
}
</entry>
<entry key='forward.json'>true</entry>

When I test it it says

WARN: [0efc9b06] error - The template variable 'phone' has no value - IllegalArgumentException (... < HttpSmsClient:85 < *:102 < NotificatorSms:49 < NotificationManager:111 < ...)
Anton Tananaev4 years ago

Your URL is clearly invalid.

CrossFire101004 years ago

Hi Anton, it seems its invalid due to the {phone} variable right. Any advice on how to pass the user's account phone into the URL?

Anton Tananaev4 years ago

I don't think it's supported.

CrossFire101004 years ago

Do you think that API has no be changed or the URL can be fixed, what would you suggest

CrossFire101004 years ago

I have managed to get past that error by changing API's to this one
API Doc (Really short)
According to the documentation this worked for me on CURL but I cant get traccar to execute it

curl -i -X POST -H 'Content-Type: application/json' -d '{"number": "521X12XXXXXXX", "msg": "TESTING...."}' http://5X.XX.XX.X8:3001/chat/send

Now the default.xml looks like this

<entry key='notificator.sms.manager.class'>org.traccar.sms.HttpSmsClient</entry>
<entry key='sms.http.url'>http://5X.XX.XX.X8:3001/chat/send</entry>
<entry key='sms.http.template'>{"number": "{phone}","msg": "{message}"}</entry>

But now I am getting this error sadly

WARN: SMS send failed - HTTP 404 Not Found - NotFoundException (...)
Anton Tananaev4 years ago

Looks like the API is returning 404 error.

CrossFire101004 years ago

It worked now I had to change URL from http://5X.XX.XX.X8:3001/chat/send to http://5X.XX.XX.X8:3001/send... I was my mistake the whole time