Add content type as a header. HTTP shouldn't be a problem.
Thank you for your answer. How can I add it? Is there some config.xml setting I can use to add a header? Can you provide an example?
Check the documentation:
I have. For sms, there’s “sms.http.authorizationHeader”. I’m sorry, I don’t know how I can use it to specify a content header.
Hmm. I thought we supported other headers. Yeah, looks like there's no way. I guess the last thing left is check the request and response using Wireshark or something similar.
I’ll do that once I have a bit more time. However, may I suggest adding a notification option for a generic API call? Maybe just the ability to run a generic command on the command line. If I could just write the “curl -X POST <etc>” line into a parameter in the config.xml, and then have Traccar execute that generic command on a notification event, all of this hassle would be avoided. And anyone else who wants to connect Traccar notifications to whatever else can also use this.
What would be the difference between generic API and what we already have with SMS?
Sms only permits sending an http request (in theory, because in practice I’m trying to do that and it’s not working).
What I’m suggesting is running a generic command-line command, like “curl”, “echo {message} > log.txt”, “sh my_script.sh”, etc
Command line is not really an API and I'm not sure I like the idea of allowing arbitrary command line execution.
That’s a reasonable concern, however it’s not arbitrary, it’s what the admin writes on the config.xml file. But if generic command-line execution is not your cup of tea, then I would still suggest a generic http API call. The options available in the current SMS implementation seem to not be enough (ex: content header, as you suggested).
Feel free to create a ticket for it.
In other words, if the SMS implementation is under the hood an http API call, then provide all the options in the config.xml to allow any http call, fully configured to the user’s content.
Sure.
So I had a little bit of time and looked into this with Wireshark. The Traccar config.xml file has these two lines:
<entry key='sms.http.url'>http://apprise:8000/notify/apprise</entry>
<entry key='sms.http.template'>{"tag": "all", "title": "Traccar", "body":"{message}"}</entry>
I can confirm that running the following command in the command line inside the traccar docker container works (i.e. it shows up on the wireguard capture and the notification is received on my phone, as normal):
curl -X POST -d '{"tag": "all", "title": "xxx", "body": "yyy"}' -H "Content-Type: application/json" http://apprise:8000/notify/apprise
But if I press "Test Channels" in the Traccar web interface (with the SMS channel selected), the wireguard capture does not show anything. So this is conclusively on Traccar's side, something in the code must be preventing it from sending the POST request...
(I could only post now because I kept getting "Too many requests"...)
How do you suggest I add the content type?
Is the problem maybe because it's over http instead of https?