Oct-01-2019, 03:28 PM
Hi there,
so i want to read some sms received in my huawei modem.
For that i m tryin to first get the token and session id from the 'http://192.168.8.1/api/webserver/SesTokInfo page
then try to reuse this token in the page http://192.168.8.1/api/sms/sms-list
but i got this error
so this is how my code looks
so i want to read some sms received in my huawei modem.
For that i m tryin to first get the token and session id from the 'http://192.168.8.1/api/webserver/SesTokInfo page
then try to reuse this token in the page http://192.168.8.1/api/sms/sms-list
but i got this error
<error> <code>125002</code> <message></message> </error>which mean that i don t have the right token value, what i m wondering about.
so this is how my code looks
import hashlib 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 = '<?xml version = "1.0" encoding = "UTF-8"?>\n' post_data += '<request><PageIndex>1</PageIndex><ReadCount>3</ReadCount><BoxType>1</BoxType><SortTyp$ headers = {'Content-Type': 'text/xml; charset=UTF-8', '__RequestVerificationToken': token } api_url = BASEURL + '/api/sms/sms-list' logonresponse = session.post( api_url, data=post_data, headers=headers, cookies=sessioncookies) logonresponse2 = session.get( api_url, data=post_data, headers=headers, cookies=sessioncookies) result = BeautifulSoup(logonresponse.text, 'html.parser') for r in result: print(r)can someone helo me with the troubleshooting please?