$AzureDevOpsPAT = 'blablabla'
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic '+
[Convert]::ToBase64String([Text.Encoding]:: ASCII.GetBytes(":$($AzureDevOpsPAT)")) }
$OrganizationName = "orgname"
$UriOrganization= "https://dev.azure.com/$($OrganizationName)/"
$WorkItemType = "task" #set there the WorkItemType
$WorkItemTitle = "Test from Powershell" #set the Title
$ProjectName = "projectname"; # set the ProjectName
$uri = $UriOrganization + $ProjectName + "/apis/wit/workitems/$" + $WorkItemType + "?api-version=5.1"
echo $uri
$body="[
{
`"op`": `"add`",
`"path`": `"/fields/System.Title`",
`"value`":`"$($WorkItemTitle)`"
}
]"
Invoke-RestMethod -Uri $uri -Method POST -Headers $AzureDevOpsAuthenicationHeader -ContentType "application/json-patch+json" -Body $body
My Personal Access Token have full access and my user is a Project Collection Administrator.