请告诉我如何使用 Rest API 和 powershell 更新(例如文本)Azure DevOps Wiki 页面。也许有人有一个更新 Wiki 页面的脚本。我可以使用此 powershell 脚本创建 Wiki 页面和内容。例如:
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$uri = "https://dev.azure.com/fabrikam/{project}/_apis/wiki/wikis/{wikiIdentifier}/pages?path=SamplePage731&api-version=5.0"
$body = @"
{
"content": "test"
}
"@
$result = Invoke-RestMethod -Uri $uri -Method Put -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $body
Run Code Online (Sandbox Code Playgroud)
错误按摩:
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"添加操作中指定的页面 '/SamplePage129' 已存在于 wiki 中。请指定新的页面路径。" ,"typeName":"Microsoft.TeamFoundation.Wiki.Server.WikiPageAlreadyExistsException, Microsoft.TeamFoundation.Wiki.Server","typeKey":"WikiPageAlreadyExistsException","errorCode":0,"eventId":3000} 位于第 22 行字符:11 + $结果 = Invoke-RestMethod -Uri $uri -Method Put -ContentType "appli ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke- …