Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4358 Lượt xem

I am trying to my site using the api. Here is my script

from xmlrpc import client

domain = "url"
user = 'user'
password = "password"
db = 'db'

api = client.ServerProxy("https://%s/xmlrpc/2/object" % domain)
common = client.ServerProxy("https://%s/xmlrpc/2/common" % domain)
uid = common.authenticate(db, user, password, {})


I keep getting this error "ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)".

This script works on another pc with the same OS so im not sure what the problem is.


This is the full traceback

Traceback (most recent call last):
File "C:\Users\User\Documents\odoo\Report\\.py",\\ line\\ 162,\\ in\\ main
\\ \\ \\ \\ comp\\ =\\ od\\.session\\(DOMAIN,\\ DB,\\ USER,\\ PASSWORD\\)
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^\\^
\\ \\ File\\ "C:\Users\User\Documents\odoo\odoodata\odooapi\.py",\ line\ 15,\ in\ __init__
\ \ \ \ self\.uid\ =\ common\.authenticate\(db,\ user,\ password,\ \{\}\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
\ \ File\ "C:\Users\ User \AppData\Local\Programs\Python\Python311\Lib\xmlrpc\client\.py",\ line\ 1122,\ in\ __call__
\ \ \ \ return\ self\.__send\(self\.__name,\ args\)
\ \ \ \ \ \ \ \ \ \ \ \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
\ \ File\ "C:\Users\ User \AppData\Local\Programs\Python\Python311\Lib\xmlrpc\client\.py",\ line\ 1464,\ in\ __request
\ \ \ \ response\ =\ self\.__transport\.request\(
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
\ \ File\ "C:\Users\ User \AppData\Local\Programs\Python\Python311\Lib\xmlrpc\client\.py",\ line\ 1166,\ in\ request
\ \ \ \ return\ self\.single_request\(host,\ handler,\ request_body,\ verbose\)
\ \ \ \ \ \ \ \ \ \ \ \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\xmlrpc\client\.py",\ line\ 1178,\ in\ single_request
\ \ \ \ http_conn\ =\ self\.send_request\(host,\ handler,\ request_body,\ verbose\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\xmlrpc\client\.py",\ line\ 1291,\ in\ send_request
\ \ \ \ self\.send_content\(connection,\ request_body\)
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\xmlrpc\client\.py",\ line\ 1321,\ in\ send_content
\ \ \ \ connection\.endheaders\(request_body\)
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\http\client\.py",\ line\ 1277,\ in\ endheaders
\ \ \ \ self\._send_output\(message_body,\ encode_chunked=encode_chunked\)
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\http\client\.py",\ line\ 1037,\ in\ _send_output
\ \ \ \ self\.send\(msg\)
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\http\client\.py",\ line\ 975,\ in\ send
\ \ \ \ self\.connect\(\)
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\http\client\.py",\ line\ 1454,\ in\ connect
\ \ \ \ self\.sock\ =\ self\._context\.wrap_socket\(self\.sock,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\ssl\.py",\ line\ 517,\ in\ wrap_socket
\ \ \ \ return\ self\.sslsocket_class\._create\(
\ \ \ \ \ \ \ \ \ \ \ \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\ssl\.py",\ line\ 1075,\ in\ _create
\ \ \ \ self\.do_handshake\(\)
\ \ File\ "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

No change

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Can you try with below code and see how it goes:

import xmlrpc.client

url = 'url'
db = 'test_db'
username = 'demo'
password = 'demo'

common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})


Official Documentation: https://www.odoo.com/documentation/16.0/developer/api/external_api.html


Thanks  & Regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 1 19
5821
2
thg 11 23
18627
0
thg 1 18
4707
1
thg 11 24
1689
1
thg 1 24
1311