I generate release note automatically when ever the build is triggered. My aim is to create a wiki page from the release note. I followed the powershell script on https://scatteredcode.net/publishing-release-notes-to-tfs-vsts-wiki-during-release/
The script ran successfully but the wiki sub page did not get created. The aim is to create a sub page "test" under the PartsUnlimitedWiki page.
PowerShell Script
I tested with below PowerShell script, and it can work will to create/update the sub-page with the content. You can reference it to update your script.
$pat = "{Personal Access Token}"
$base64Token = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "", $pat)))
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", ("Basic {0}" -f $base64Token))
$headers.Add("Content-Type", "application/json")
$uri = "https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis/{wiki-name}/pages?path=/parent-page-name/sub-page-name&api-version=7.0"
$content = [IO.File]::ReadAllText("path/to/release-notes.md")
$body = @{content = $content} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method PUT -Uri $uri -Headers $headers -Body $body
When you run the script in Azure Pipelines, the value of authorization token can be either your PAT (Personal Access Token) or the System.AccessToken
(Job access token). You can follow the documentation "Job access tokens" to check and assign System.AccessToken
with the required permissions to access Wiki.