You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from pydiscourse import DiscourseClient
client = DiscourseClient(
'https://www.mydomain.com',
api_username='admin',
api_key='alsdjfaldjfajdfajds;fjalsdf')
# update a post, it works
post_id = 23232
new_content = "something to change"
client.update_post(post_id, new_content, edit_reason="")
# exception here
topic_url = "https://www.mydomain.com/t/2427.json"
client.update_topic(topic_url, "new title")
exception as below.
>>> client.update_topic(topic_url, "title")
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connection.py", line 203, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/urllib3/util/connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py", line 962, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 491, in _make_request
raise new_e
File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
self._validate_conn(conn)
File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1092, in _validate_conn
conn.connect()
File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connection.py", line 611, in connect
self.sock = sock = self._new_conn()
^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connection.py", line 210, in _new_conn
raise NameResolutionError(self.host, self, e) from e
urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x101c527d0>: Failed to resolve 'www.mydomain.comhttps' ([Errno 8] nodename nor servname provided, or not known)
seems, it complains about the server name, but the url is correct. it works fine if call it with request directly as below.
# update the topic title with requests, it works
topic_url = "https://www.mydomain.com/t/2427.json"
headers = {
'Api-Key': 'asdfasdfasdfasdfadfa',
'Api-Username': 'admin'
}
payload = {
'title': "new title"
}
# Send the PUT request to update the topic title
response = requests.put(topic_url, headers=headers, json=payload)
if response.status_code == 200:
print('Topic title updated successfully.')
The text was updated successfully, but these errors were encountered:
I don't have time to debug in detail right now but this line looks like it might hold a clue
urllib3.exceptions.NameResolutionError: <urllib3.connection.HTTPSConnection object at 0x101c527d0>: Failed to resolve 'www.mydomain.comhttps' ([Errno 8] nodename nor servname provided, or not known)
Specifically 'www.mydomain.comhttps' appears to have https in the wrong place. I'm not sure how that could happen :|
python 3.11
pydiscourse latest 1.6.1
exception as below.
seems, it complains about the server name, but the url is correct. it works fine if call it with request directly as below.
The text was updated successfully, but these errors were encountered: