Hi Anton,
Need your advice on what payload I should send via API in order to send SMS command to a device.
Currently, with the code below, I can send a HEX command to the device via server (command appears in the logs) but I need to modify this code to send the same command as SMS:
API call:
headers['content-type'] = "application/json";
final response = await http.post(
Uri.parse(serverURL + "/api/commands/send"),
body: string,
headers: headers
);
Confing file:
<entry key='sms.http.url'>SMS Gateway URL</entry>
<entry key='sms.http.authorization'>TOKEN</entry>
<entry key='sms.http.template'>
{
"to": "{phone}",
"message": "{message}"
}
</entry>
Please, note if I dispatch the same command via traccar web interface as custom command and I select "Send via SMS" checkbox, the SMS is sent and the device receives it. So I believe the config is correct and instead I should modify the API call above to "request" an SMS send method instead of server one.
Have you checked what the official web app is sending? It uses the same API.
Is there a way to actually check the payload sent by web app?
I was looking at the Command model here
I see this code TYPE_SEND_SMS = "sendSms";
but not sure if this is the right parameter and how to embed it in the API call.
You can see all network requests in a browser developer tools.
Good advice, it's so simple that I must bang my head repeatedly for not figuring this out yet.
So the answer is textChannel = true
for SMS and textChannel = false
for server command.
Thank you for the help, really appreciate your commitment to the project!
Hi Anton,
Need your advice on what payload I should send via API in order to send SMS command to a device.
Currently, with the code below, I can send a HEX command to the device via server (command appears in the logs) but I need to modify this code to send the same command as SMS:
API call:
headers['content-type'] = "application/json"; final response = await http.post( Uri.parse(serverURL + "/api/commands/send"), body: string, headers: headers );
Confing file:
<entry key='sms.http.url'>SMS Gateway URL</entry> <entry key='sms.http.authorization'>TOKEN</entry> <entry key='sms.http.template'> { "to": "{phone}", "message": "{message}" } </entry>
Please, note if I dispatch the same command via traccar web interface as custom command and I select "Send via SMS" checkbox, the SMS is sent and the device receives it. So I believe the config is correct and instead I should modify the API call above to "request" an SMS send method instead of server one.