e3372
e3372 copied to clipboard
Error 125002 while trying to read messages from huawei modem
so i want to read some sms received in my huawei modem. for this i have to take a token value from one page and reuse it in another pages (sms-list) of my modem
but i got this error 125002 which means that my token value is not accurate
<error> <code>125002</code> <message></message> </error>
here is my code
`
import base64
import binascii
import xml.etree.ElementTree as ET
from datetime import datetime
import requests
from bs4 import BeautifulSoup
BASEURL = 'http://192.168.8.1'
session = requests.Session()
reqresponse = session.get(BASEURL + '/api/webserver/SesTokInfo')
if reqresponse.status_code == 200:
root = ET.fromstring(reqresponse.text)
for results in root.iter('SesInfo'):
sessionid = results.text
print("the sessionId is", sessionid)
for results in root.iter('TokInfo'):
token = results.text
print("The token is", token)
sessioncookies = reqresponse.cookies
post_data = '\n'
post_data += '
`
from this bash script, i m getting all my message list and it is almost the same principle
RESPONSE=
curl -s -X GET http://192.168.8.1/api/webserver/SesTokInfo COOKIE=
echo "$RESPONSE"| grep SessionID=| cut -b 10-147 TOKEN=
echo "$RESPONSE"| grep TokInfo| cut -b 10-41`
DATA="
`
what did i missed in python please?
so i want to read some sms received in my huawei modem. for this i have to take a token value from one page and reuse it in another pages (sms-list) of my modem
but i got this error 125002 which means that my token value is not accurate
<error> <code>125002</code> <message></message> </error>
here is my code
` import base64 import binascii import xml.etree.ElementTree as ET from datetime import datetime import requests from bs4 import BeautifulSoup BASEURL = 'http://192.168.8.1' session = requests.Session() reqresponse = session.get(BASEURL + '/api/webserver/SesTokInfo') if reqresponse.status_code == 200: root = ET.fromstring(reqresponse.text) for results in root.iter('SesInfo'): sessionid = results.text print("the sessionId is", sessionid) for results in root.iter('TokInfo'): token = results.text print("The token is", token) sessioncookies = reqresponse.cookies post_data = '\n' post_data += '131001\n' headers = {'Content-Type': 'text/xml; charset=UTF-8', '__RequestVerificationToken': token,'X-Requested-With: XMLHttpRequest'} api_url = BASEURL + '/api/sms/sms-list' logonresponse = session.post( api_url, data=post_data, headers=headers, cookies=sessioncookies) result = BeautifulSoup(logonresponse.text, 'html.parser') for r in result: print(r)
`
from this bash script, i m getting all my message list and it is almost the same principle
RESPONSE=
curl -s -X GET [http://192.168.8.1/api/webserver/SesTokInfo](http://192.168.8.1/api/webserver/SesTokInfo%60) COOKIE=
echo "$RESPONSE"| grep SessionID=| cut -b 10-147TOKEN=
echo "$RESPONSE"| grep TokInfo| cut -b 10-41` DATA="13 100 1" curl -b $COOKIE -c $COOKIE -H "X-Requested-With: XMLHttpRequest" --data "$DATA" http://192.168.8.1/api/sms/sms-list --header "__RequestVerificationToken: $TOKEN" --header "Content-Type:text/xml"`
what did i missed in python please?
I have the same problem as you. Have you solved it?
this is a similar problem that I faced. and this is the solution. I hope this helps.
import xml.etree.ElementTree as ET import requests from bs4 import BeautifulSoup import xmltodict
BASEURL = 'http://192.168.8.1' signal = BASEURL + '/api/device/signal'
session = requests.Session() reqresponse = session.get(BASEURL + '/api/webserver/SesTokInfo') if reqresponse.status_code == 200: _dict = xmltodict.parse(reqresponse.text).get('response', None) #here is the correct method to get sessionid and token values
response = session.request( 'get', signal, cookies={ 'session': _dict['SesInfo'] }) result = BeautifulSoup(response.text, 'html.parser')
print(result)
Hello @ReineVanessa @vvrf @TsiaprasTilemachos, sorry for not seeing this earlier. I don't have any E3372 device anymore to test so I'm archiving this repo. Best, Aarno