Reputation: 1
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.
Upvotes: 0
Views: 2752
Reputation: 18978
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:
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)"
Upvotes: 1