可能有一些方法可以从我的研究中访问RESTful API。 Httpclient?使用ID和密码可能不安全。 使用个人令牌访问Azure Devops的方式是什么? 任何示例代码? 下面的代码是我尝试过的,它显示凭据失败。
谢谢。
powershell代码
function InputToPowerBI {
param ([string]$type,[string]$title,[string]$assignedTo,[string]$state)
$endpoint = "address of the end point"
$payload = @{
"Type" =$type
"Title" =$title
"Assigned To" =$assignedTo
"State" =$state
"Area Path" =$areaPath
"Tags" =$tag
"Comment Count" =$commentCount
}
$json = ConvertTo-Json @($payload);
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body $json
}
GetData;
function GetData
{
try
{
$personalAccessToken="Personal token such as eiejr22837482";
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalToken)"))
$header = @{authorization = "Basic $token"}
$projectsUrl = "address of the current sprint from Azure DevOps"
$projects = Invoke-RestMethod -Uri $projectsUrl -Method Get -ContentType "application/json" -Headers $header
$projects.value | ForEach-Object {
}
}
catch
{
}
}