如何检索 Azure DevOps Wiki 页面列表以便能够对其进行编辑?

问题描述 投票:0回答:2

我正在使用 .NET 客户端 API 访问我们的 Azure DevOps 服务器。

如何检索维基页面列表,以便我可以编辑它们的内容并存储更改?

这是我到目前为止得到的:

using (WikiHttpClient client = new WikiHttpClient(App.ProjectUrl, new VssCredentials()))
{
    using (Stream s = await client.GetPageTextAsync(ConfigurationManager.AppSettings["RepositoryContext"], ConfigurationManager.AppSettings["WikiPageName"]))
    using (StreamReader sr = new StreamReader(s))
    {
        string text = sr.ReadToEnd();
    }
}

我似乎找不到正确的

WikiPageName
,所以我需要一个所有项目的Wiki页面的列表,以便能够枚举和检索页面的正确名称。


编辑

这是要求的截图:

这是使用的网址:

http://tfs.***.***.loc:8080/tfs/***Collection/******Manager-Plus/_wiki/wikis/******Manager-Plus.wiki?wikiVersion=GBwikiMaster&pagePath=%2FDM%252DRelease%C3%BCbersicht&pageId=6

这是我使用的值:

<add key="WikiPageName" value="DM-Releaseübersicht"/>

tfs azure-devops azure-devops-rest-api azure-devops-server-2019
2个回答
1
投票

您可以使用方法

GetAllWikisAsyc
获取维基元数据,在结果中您将获得
wikiIdentifier
以在方法
GetPageTestAsync
中使用。但是您将需要页面路径,目前您无法使用 API 获取路径,您应该手动检查它(是 wiki 页面标题)并将其放入方法中:

var wikis = client.GetAllWikisAsync("Project").Result.
using (Stream S = client.GetPageTextAsync("Project", wikis[0].Id, path: "Test").Result)
{
    using (StreamReader sr = new StreamReader(s))
    {
        string text = sr.ReadToEnd();
    }
};

0
投票

对不起,我今天遇到了这个。这是一个很老的问题,但我认为答案可能对某些人仍然有用。 为了获得特定维基页面的所有子页面的列表,您需要做的就是将

recursionLevel
参数传递给任何
GetPage...Async
方法。

下面的代码,例如,获取最首页及其所有子页面:

var page = await client.GetPageAsync(
  ConfigurationManager.AppSettings["RepositoryContext"],
  ConfigurationManager.AppSettings["WikiPageName"],
  path: "/",
  recursionLevel: VersionControlRecursionType.Full);

希望对您有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.