As POST/GET and I/O POST/GET is removed in RutOS 7.14 I need to change to the API.
I am struggling with sending a SMS via the API. It was so easy using POST/GET.
Could you please provide an example as the documentation does not have an example in.
Could you confirm whether you’re performing the initial authentication action before executing the API call to send the SMS? In the new RutOS API, you first need to authenticate to receive a valid session token before calling any endpoints.
You can find the instructions on authentication here:
Regarding your modem parameter — the identifier might differ depending on your specific device modem. To check the actual modem ID, you can run this command via SSH:
Alternatively, the modem ID can be found in the /etc/config/network config file under the config interface 'mob1s1a1' section by looking for the option modem line.
I hope this clarifies it, and feel free to ask if you have any questions or need assistance here.
yes I do the authentication with: (remark User and passwords are changed here)
curl -X POST “https://192.168.1.254/api/login”
-H “Content-Type: application/json”
-d ‘{“username”: “user”, “password”: “password”}’
-k
and I get back:
{“success”:true,“data”:{“username”:“user”,“token”:“eb300d60dff3b6ef388dc1bd5ca24595”,“expires”:299}}
Than I ask for the modem:
curl -X GET “https://192.168.1.254/api/modems/apns/status”
-H “Content-Type: application/json”
-H “Authorization: Bearer eb300d60dff3b6ef388dc1bd5ca24595”
-k
I get back:
{“success”:true,“data”:[{“apns”:[{“password”:“”,“apn”:“web.yesss.at”,“user”:“”,“id”:324,“carrier”:“yesss!”,“pdptype”:“0”,“auth”:“none”}],“modem”:“1-1”}]
But send Message does not work:
(I am not allowed to put in the curl command a third time.
3 links limitation for new users, forum editor thinks command example is a link)
Command is like in my first post with
-H “Content-Type: application/json”
-H “Authorization: Bearer eb300d60dff3b6ef388dc1bd5ca24595”
-d ‘{“number”:“+phonenumber”,“message”:“This is an SMS”,“modem”:“1-1”}’
-k
I get back:
{“success”:false,“errors”:[{“source”:“Validation”,“code”:102,“error”:“No arguments provided for action”,“section”:“send”}]}
With the line:
-d ‘{“data”:{“number”:“+phonenumber”, “message”:“This is an SMS”, “modem”:“1-1”}}’
it worked.
I got:
{“success”:true,“data”:{“sms_used”:1}}