Issue
This is my first question, and i'm not a native speaker, please don't be hard on me :)
I'm trying to do sms things with the api read/send is ok, but when it comes to deleting part it always return error 125005, which is i believed related to session and token.
It's very limited information on internets about example on how to used the api.
Here's the scrpt:
#!/bin/bash
MODEM_IP="192.168.9.1"
curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > ses_tok.xml
COOKIE=`grep "SessionID=""ses_tok.xml | cut -b 10-147`
TOKEN=`grep "TokInfo" ses_tok.xml | cut -b 10-41`
curl -s -X POST "http://$MODEM_IP/api/sms/sms-list" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" -d "<request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>" > modem_status.xml
#cat modem_status.xml
#read index
readarray -t array_index <<< "$(xmlstarlet sel -t -m "//Index" -v . -n modem_status.xml)"
rm -f result_status.xml
touch result_status.xml
for ((i=0; i<${#array_index[@]}; i++ ))
do
index[$i]=$(printf ${array_index[$i]} | tr -d '\n\r ')
#printf "${index[$i]} "
printf "\n${index[$i]}\n" >> result_status.xml
curl -s -X POST "http://$MODEM_IP/api/sms/delete-sms" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" -d "<?xml version="1.0" encoding="UTF-8"?><request><Index>${index[$i]}</Index></request>" >> result_status.xml
done
cat result_status.xml
errors:
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>125003</code>
<message></message>
</error>
Maybe, i missed something that i didn't notice before.
TIA
Solution
Maybe too late but I had the same issue and maybe this helps also other users looking for it.
In my case the token/cookie already expired right before the delete command. I don't think that it is a time component involved but more like the combination is only valid for one API call.
I get a new token/cookie right before the delete command and now it works for me. Hope this helps.
Cheers Chris
Answered By - C. Jani Answer Checked By - Katrina (WPSolving Volunteer)