Всем салют!
Не получается авторизоваться пост запросом из этой ссылки:
import requests
import time
if __name__ == "__main__":
try:
s = requests.session()
headers = {
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36',
'ForceUseSession': 'true'
}
data={'UserName': 'Login', 'UserPassword': 'Password'}
p = s.post('https://mysite.ru/ServiceModel/AuthService.svc/Login', headers=headers, data=data)
s.cookies
print(p.text)
except Exception as e:
print(f"\n\n\n\n{e}\n\n\n")
time.sleep(50)Возвращает такую ошибку:
requests.packages.urllib3.connectionpool - DEBUG - "POST /Login HTTP/1.1" 400 3069
<?xml version="1.0" encoding="utf-8"?>
Request Error
Request Error
The server encountered an error processing the request. The exception message is 'There was an error checking start element of object of type Core.ServiceModelContract.AuthToken. Encountered unexpected character 'U'.'. See server logs for more details. The exception stack trace is:
at System.Runtime.Serialization.XmlObjectSerializer.IsStartObjectHandleExceptions(XmlReaderDelegator reader)
at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.ReadObject(Message message)
at System.ServiceModel.Dispatcher.SingleBodyParameterDataContractMessageFormatter.ReadObject(Message message)
at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
Нравится
Решено!
Вдруг кому пригодится решение:
p = s.post('https://mysite.ru/ServiceModel/AuthService.svc/Login', headers=headers, data=json.dumps(data))
Решено!
Вдруг кому пригодится решение:
p = s.post('https://mysite.ru/ServiceModel/AuthService.svc/Login', headers=headers, data=json.dumps(data))