0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Confluence:Excel VBAからConfluenceのページを取得する (Server/DataCenter)

Posted at

手順

1.VBA-JSONの追加

1)以下よりVBA-JSONをダウンロードします

2)「JsonConverter.bas」 をプロジェクトに追加します

image.png

2.参照設定の追加

「Microsoft XML v6.0」と、「Microsoft Scripting Runtime」を追加します。
image.png

3.VBAコードの追加

Microsoft Visual Basic for Applications を開き、次のコードを入力し、実行します。

Sub GetPage()
  Dim ohttpReq As New XMLHTTP60
  Dim dJsonParsed As Dictionary
  Dim sUrl As String

  ' 取得したい情報(項目)を増やしたい場合はexpandの値を変更する
  ' 以下の場合は本文とラベルを指定している
  sUrl = "https://<ConfluenceのベースURL>/rest/api/content/<ページID>?expand=body.storage,metadata.labels"

  ' HTTPリクエストする
  With ohttpReq
    .Open "GET", sUrl
    .setRequestHeader "Authorization", "Basic <Basic認証のユーザー名とパスワード(Base64エンコード)>"
    .setRequestHeader "Content-Type", "application/json; charset=UTF-8"
    .setRequestHeader "X-Atlassian-Token", "no-check"
    Debug.Print .responseText ' HTTPレスポンスをイミディエイトに出力

    ' パース結果は dJsonParsed("id") や dJsonParsed("space")("id") のような形で取得可能
    Set dJsonParsed = JsonConverter.ParseJson(.responseText)
  End With
End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?