I am getting below error when I am trying to create a Work Item in Azure Devops using the Rest API.
This is the PowerShell script I am using
$body ='[{"op": "add", "path": "/fields/System.Title", "from": null, "value": "Initiative Code"}]' | ConvertTo-Json
$body = $body | ConvertFrom-Json
$supportAreaUri = 'https://MyOrganization.visualstudio.com/TestTeam1/_apis/wit/workitems/$Initiative?api-version=6.0'
$supportAreaUri = [uri]::EscapeUriString($supportAreaUri)
$supportArea = Invoke-RestMethod -Method Post -Uri $supportAreaUri -Headers $Header -ContentType application/json -Body $body
I am getting this error when running the code:
"$id": "1",
"innerException": null,
"message": "The request indicated a Content-Type of "application/json" for method type "POST" which is not supported. Valid content types for this method are: application/json-patch+json.",
"typeName": "Microsoft.VisualStudio.Services.WebApi.VssRequestContentTypeNotSupportedException, Microsoft.VisualStudio.Services.WebApi",
"typeKey": "VssRequestContentTypeNotSupportedException",
"errorCode": 0,
"eventId": 3000
I am getting same error when I try in Postman as Post
request.