๊ธ€ ์ž‘์„ฑ์ž: ๋˜ฅํด๋ฒ .
๋ฐ˜์‘ํ˜•

 ์‹ค๋ฌด์—์„œ Confluence ๋ฌธ์„œ ์ž๋™ํ™”๊ฐ€ ํ•„์š”ํ•˜์—ฌ REST API์— ๋Œ€ํ•˜์—ฌ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ •๋ฆฌํ•˜์˜€๋‹ค.

์ž์‹ ์ด ํ™˜๊ฒฝ์ด Cloud ํ™˜๊ฒฝ์ด๋ƒ, ์ž์ฒด ์„œ๋ฒ„๋ƒ์— ๋”ฐ๋ผ ์กฐ๊ธˆ ๋‹ค๋ฅด๋ฏ€๋กœ ์•„๋ž˜ ๋งํฌ๋“ค์€ ์ฐธ๊ณ ํ•œ๋‹ค.

 

API ๋ฌธ์„œ

* Cloud

https://developer.atlassian.com/cloud/confluence/rest/v1/

 

The Confluence Cloud REST API

 

developer.atlassian.com

 

* ์ž์ฒด ์„œ๋ฒ„

https://docs.atlassian.com/ConfluenceServer/rest/8.5.0-m04/#api/admin/group-create

 

https://docs.atlassian.com/ConfluenceServer/rest/8.5.0-m04/#api/admin/group-create

Deletes a labels to the specified content. When calling this method through REST the label parameter doesn't accept "/" characters in label names, because of security constraints. For this case please use the query parameter version of this method (/conten

docs.atlassian.com

 

2024.12.05 ํ˜„์žฌ ๊ธฐ์ค€, Cloud ํ™˜๊ฒฝ์€ Rest v2๋ฅผ ์ง€์›ํ•˜์ง€๋งŒ, ์ž์ฒด ์„œ๋ฒ„๋Š” v1๋ฐ–์— ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.
๋ญ ๊ธฐ๋ณธ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ์žˆ์–ด ํฐ ์ฐจ์ด๋Š” ์—†์„ ๋“ฏ?

 

 

์ธ์ฆ

 REST API ์š”์ฒญ์„ ํ•˜๊ธฐ ์ „ ๋‹จ๊ณ„๋กœ ํ—ค๋”์— ์ธ์ฆ ์ •๋ณด๋ฅผ ๋‹ด์•„์•ผ ํ•œ๋‹ค.

์ธ์ฆ ๋ฐฉ๋ฒ•์€ ํฌ๊ฒŒ 2๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

 

1. ID / PASSWORD ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•
2. ์ธ์ฆ ํ† ํฐ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

 

1๋ฒˆ ๋ฐฉ๋ฒ•์€ ๋ณด์•ˆ์ ์œผ๋กœ ์ทจ์•ฝํ•˜๊ธฐ ๋•Œ๋ฌธ์— 2๋ฒˆ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•œ๋‹ค.

์ธ์ฆ ํ† ํฐ์„ ๋ฐœ๊ธ‰ ๋ฐ›๋Š” ๋ฐฉ๋ฒ•์€ ์ž์ฒด ์„œ๋ฒ„๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์•„๋ž˜์™€ ๊ฐ™์ด ๋ฐœ๊ธ‰๋ฐ›์œผ๋ฉด ๋œ๋‹ค.

 

๊ฐœ์ธ์šฉ ์•ก์„ธ์Šค ํ† ํฐ

 

 [ํ™˜๊ฒฝ ์„ค์ •] -> [๊ฐœ์ธ์šฉ ์•ก์„ธ์Šค ํ† ํฐ] -> [ํ† ํฐ ๋งŒ๋“ค๊ธฐ]

๋งŒ๋“ค์–ด์ง„ ํ† ํฐ์€ ๋‹ค์‹œ ๋ฐœ๊ธ‰๋ฐ›์ง€ ๋ชปํ•˜๋ฏ€๋กœ ์ค‘์š”ํ•œ ์žฅ์†Œ์— ์ €์žฅํ•ด๋‘”๋‹ค.

 

ํŒŒ์ด์ฌ ์˜ˆ์ œ

ID / PASSWORD ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

import requests
import base64

# ์ธ์ฆ ์ •๋ณด
email = "your-email@example.com"
password = "your-password"

# Basic ์ธ์ฆ ํ—ค๋” ์ƒ์„ฑ
auth_string = f"{email}:{password}"
auth_encoded = base64.b64encode(auth_string.encode()).decode()  # Base64๋กœ ์ธ์ฝ”๋”ฉ

# ์š”์ฒญ ํ—ค๋”์— Authorization ์ถ”๊ฐ€
headers = {
    "Authorization": f"Basic {auth_encoded}",
    "Accept": "application/json",
}

# Confluence API ์—”๋“œํฌ์ธํŠธ
url = "https://your-confluence-site.atlassian.net/wiki/rest/api/content"

# GET ์š”์ฒญ
response = requests.get(url, headers=headers)

# ์‘๋‹ต ์ฒ˜๋ฆฌ
if response.status_code == 200:
    print("Response Data:", response.json())
else:
    print("Error:", response.status_code, response.text)

 

์ธ์ฆ ํ† ํฐ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

import requests

# Confluence API ์ •๋ณด
BASE_URL = "https://your-confluence-site.atlassian.net/wiki/rest/api/content"
API_TOKEN = "your-api-token"

# ํŽ˜์ด์ง€ ์ •๋ณด
PAGE_ID = "123456"  # ํŽ˜์ด์ง€ ID

# GET ์š”์ฒญ์œผ๋กœ ํŽ˜์ด์ง€ ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
response = requests.get(
    f"{BASE_URL}/{PAGE_ID}",
    headers={
        "Authorization": f"Bearer {API_TOKEN}",  # Bearer ์ธ์ฆ
        "Accept": "application/json"  # JSON ์‘๋‹ต์„ ์š”์ฒญ
    }
)

# ์‘๋‹ต ์ฒ˜๋ฆฌ
if response.status_code == 200:
    print("Page data:", response.json())
else:
    print("Failed to fetch page data:", response.status_code, response.text)



๋ฐ˜์‘ํ˜•