I am trying to develop a connection with the confluence pages using api but I am getting an error again and again:
ConnectionError: HTTPSConnectionPool(host='confluence.hrs.io', port=443): Max retries exceeded with url: /rest/api/content (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f9e571e3370>: Failed to resolve 'confluence.hrs.io' ([Errno -2] Name or service not known)"))
I need solution for creating a successful connection using the API.
Thanks,
Kompal
I corrected the VPC issue but now I have issue with the authorization its throwing an error - 401. I am using my email id and created api token. Here is the code for that:
email = "my email" # Your Atlassian email
api_token = "api token created"
base_url = "company url"
space_key = "key"
page_title = "title"
headers = {
"Authorization": "Basic api token",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
# Display the response
print("Status Code:", response.status_code)
print("Response:", response.json() if response.ok else response.text)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
have you setup https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/#supplying-basic-auth-headers the token like written here ? The base64 encoded string , peoviding email adress and generated api token ?
BR
Kai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
To access Confluence REST APIs using Basic Authentication, you need to include an Authorization header in your HTTP requests.
This header should contain the word "Basic" followed by a base64-encoded string of your email adress and token in the format username:token and encode it to base64. The generated string you can use in your headers as token
Hoiw you can generate it its written under the link https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/#supplying-basic-auth-headers
BR
Kai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your response:
I tried to check pt 1:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
here is hoiw you can perform a quick DNS-check for your Confluence URL
Open Command Prompt
Press Win + R → type cmd → Enter.
Run nslookup
nslookup confluence.hrs.io/wiki
There must be one or more IP addresses shown → DNS is resolving the name.
if can’t find the name isn’t known to the DNS server you’re using.
Inside the corporate network (or over VPN): your PC asks internal DNS servers and traffic must be allowed through internal firewalls to port 443 on the Confluence.
Outside the network without VPN: the hostname must exist in public DNS and the Confluence IP must accept inbound HTTPS from the Internet.
With nslookup you can confirm the name is visible to the DNS server you’re currently using, and your network location (LAN, VPN, or public Internet) determines which DNS server answers and whether firewalls permit the connection.
ive you use a not public environment, you should contact your network administrator to find out, why you cant reach your confluence
BR
Kai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi and welcome ,
The error message you're encountering indicates that your Python script is unable to resolve the hostname. Could be Incorrect URL or Network Issues or DNSA Problems
Here is a simple example to use pyhton to connect to the api
import requests
from requests.auth import HTTPBasicAuth
# Replace with your Confluence credentials and URL
username = 'your_username'
api_token = 'your_api_token' # Use an API token instead of a password
url = 'https://confluence.hrs.io/rest/api/content'
# Make the request
try:
response = requests.get(url, auth=HTTPBasicAuth(username, api_token))
response.raise_for_status() # Raise an error for bad responses
print(response.json()) # Print the JSON response
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
i think
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.