I am getting an error message when using the Azure DevOps REST API (regardless of version).
Running POST https://dev.azure.com/{organisation}/{project}/_apis/wit/classificationnodes/Areas?api-version=7.1-preview.2
with a body payload
{ "name": "Very nice area" }
Does not execute and an error is returned.
"status": 415, "message": "TF400898: An Internal Error Occurred.....
From the MS article below I'd expect to have an Area created for the given Organisation and project in the URL. Note that I do not have an issue using other REST API calls to the same DevOps organisation.
I've tried adding the path in the body and the URL and various versions of the API. I'm able to update work items in the same organisation. I also get the same error when trying Iterations as well as Area.
"status": 415, "message": "TF400898: An Internal Error Occurred.....
From the error message, the 415 status indicates Unsupported Media Type error. The issue could be related to the Post Headers.
We need to set the Content-Type
to application/json
.
You can refer to the following PowerShell script to run the Rest API:
$token = "PAT"
$url="https://dev.azure.com/OrganizationName/ProjectName/_apis/wit/classificationnodes/Areas?api-version=7.1-preview.2"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$JSON = @'
{
"name": "Very nice area"
}
'@
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -Body $JSON -ContentType application/json
If you are using Postman, you can refer to the following headers.