web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Error creating Work Items via Az Devops API and Powershell

(1) ShareShare
ReportReport
Posted on by 6
Hi, I'm trying to develop a PowerShell script to create a workitem in azure devops following this post https://community.dynamics.com/blogs/post/?postid=61631256-4360-4b07-b343-43a855173cec
 
but i'm getting this error:
 
Invoke-RestMethod : 
  
    The controller for path '/orgname/projectname/apis/wit/workitems/$task' was not found or does not implement IController.
    html {
.
.
.
.
.
+ Invoke-RestMethod -Uri $uri -Method POST -Headers $AzureDevOpsAutheni ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
My script:
$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
 
Please, I don't know what's wrong :(
 
My Personal Access Token have full access and my user is a Project Collection Administrator.
I have the same question (0)
  • Verified answer
    UH-09100850-0 Profile Picture
    12 on at
    I've got the same problem and could solve it by adding "accent de grave = ` " into my URL-Call.

    Try complete URL like this:
    "https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/`$Task?api-version=7.1"

    In Microsoft documentation:
    Work Items - Create - REST API (Azure DevOps Work Item Tracking) | Microsoft Learn
    POST https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/${type}?api-version=7.1

    Seems it need to be corrected/changed to:
    POST https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/`${type}?api-version=7.1

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,869 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,182 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,109 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans