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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans