import requests,json
payload = {
'username': 'employee',
'userpassword': 'abc123'
}
login_route = '/eNextWebAPI/login'
url = 'https://lb-clus-08-01.mycompany.local/myinstance'
with requests.Session() as s:
p = s.post(url, data=payload)
print(p.text)
は、私は上記のコードでログインページに投稿しようとしたが、私が得た:APIエンドポイントを指定してログインしてトークンを取得するにはどうすればよいですか?
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
...
...
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='-----', port=443): Max retries exceeded with url: /myinstance (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/User/.PyCharmCE2017.1/config/scratches/API.py" line 13, in <module>
p = s.post(url, data=payload)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 555, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='......', port=443): Max retries exceeded with url: /myinstance (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)'),))
Process finished with exit code 1
'login_route'変数は必須ではありませんか? –
私たちはメインページにユーザー名とパスワードを投稿することもできますし、適切なヘッダーで完全なAPIパスを「取得」することもできます。 –
これで試すことができますか? 'p = s.post(url、data = payload、verify = False)'エラーは無効なSSL証明書によるものです。 –