Log in writing today, when the request is normal with the postman, with a python written request back to the server exception because finally found a data transfer of data over the last default string
import requests class HttpRequest: def http_request(self, method, url, data=None, header = None, cookie=None): if method.lower() == 'get': res = requests.get(url,data, headers = header, cookies = cookie, verify = False) elif method.lower() == 'post': res = requests.post(url, data, headers = header, cookies = cookie, verify = False) elif method.lower() == 'put': res Requests.post = (url, the Data, headers = header, Cookies = the cookie, the Verify = False) the else : Print ( " Without this method, please contact the administrator " ) return return RES IF __name__ == ' __main__ ' : Method, = ' POST ' URL = ' HTTPS:? www.account / V2 / the session / loginByOne corpId 8GUafWTqYo0o00 = ' Data = { " fullPhone " : " 86-17610296533 " , "password":"123456"} header = {'Content-Type': 'application/json'} res = HttpRequest().http_request(method, url, data, header) print(res)
Data needs to be modified to modify the code following json
import requests class HttpRequest: def http_request(self, method, url, data=None, header = None, cookie=None): if method.lower() == 'get': res = requests.get(url, json = data, headers = header, cookies = cookie, verify = False) elif method.lower() == 'post': res = requests.post(url, json = data, headers = header, cookies = cookie, verify = False) elif method.lower() == 'put': RES = requests.post (url, json = the Data, headers = header, Cookies = the cookie, the Verify = False) the else : Print ( " Without this method, please contact the administrator " ) return return RES IF __name__ == ' __main__ ' : Method = ' POST ' URL = ' HTTPS:? // Account / V2 / the session / loginByOne corpId 8GUafWTqYo0o00 = ' Data = { " fullPhone " : " 86-17610296533 " ,"password":"123456"} header = {'Content-Type': 'application/json'} res = HttpRequest().http_request(method, url, data, header) print(res)