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

Announcements

No record found.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,005 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,148 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 557 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans