0
votes

I am trying to use the Azure Dev Ops rest API to retrieve all the wiki pages from a wiki on my azure dev ops site. Though I am able to retrieve the main wiki with: https://dev.azure.com/{project name}/_apis/wiki/wikis/{wiki identifier}/

if I add /pages like so: https://dev.azure.com/{project name}/_apis/wiki/wikis/{wiki identifier}/pages

like it says on the documentation, I get a 404 page not found error. Are there more reqired fields here that I am missing? The only header I am currently passing is my PAT.

1
Hi, how is this going? Can you programmatically list the wiki pages with rest API successfully now? Feel free to share your progress with us:)Merlin Liang

1 Answers

1
votes

You can try with this api:

Get  https://dev.azure.com/{org name}/{project name}/_apis/wiki/wikis/{wikiIdentifier}/pages?path=/&recursionLevel=OneLevel&api-version=5.1

Note: If you want to list all of wiki pages, need to specified the value of recursionLevel in the url. This is the key word which specify the Recursion level for subpages retrieval.

For more details about this recursionLevel:

enter image description here

You can also refer to this doc: Get page as JSON with recursion level for more sample.

In addition, for programatically list wiki pages with rest API, here has an sample which execute with powershell can for you refer:

$uri = "https://dev.azure.com/{org name}/{project name}/_apis/wiki/wikis/{wikiIdentifier}/pages?path=/&recursionLevel=OneLevel&api-version=5.1"
$connectionToken="{Your PAT token}"
$base64AuthInfo = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$projects = Invoke-RestMethod -Uri $uri -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method GET
Write-Host "Pipeline = $($projects| ConvertTo-Json -Depth 100)"