Hello everybody,
I'm trying to create a permission report on devops using rest api. I'm following the below doc:
report/create?view=azure-devops-rest-6.0
Below is the code I currently have:
Im getting below error:
Im not sure how to move forward. I'd appreciate any help.
Thanks & regards.
I'm trying to create a permission report on devops using rest api. I'm following the below doc:
report/create?view=azure-devops-rest-6.0
Below is the code I currently have:
Code:
# Create needed variables
$OrganizationName = "myorg"
$AdminUser = "myemail@domain.com"
$Token = "pattoken"
# The Header is created with the given information.
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $AdminUser, $Token)))
$Header = @{
Authorization = ("Basic {0}" -f $base64AuthInfo)
}
# Splat the parameters in a hashtable for readability
$Uri = "[URL unfurl="true"]https://dev.azure.com/$OrganizationName/_apis/permissionsreport?api-version=6.0-preview.1"[/URL]
$Body = @{
descriptors = ""
reportName = "testreport"
resources = "collection"
}
# Store response
$Reports = (Invoke-RestMethod -Uri $Uri -Headers $Header -Method POST -Body $Body)
$Reports
Im getting below error:
Code:
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"The request indicated a Content-Type of \"application/x-[URL unfurl="true"]www-form-urlencoded\"[/URL] for method
type \"POST\" which is not supported. Valid content types for this method are: application/json,
application/json-patch+json.","typeName":"Microsoft.VisualStudio.Services.WebApi.VssRequestContentTypeNotSupportedException,
Microsoft.VisualStudio.Services.WebApi","typeKey":"VssRequestContentTypeNotSupportedException","errorCode":0,"eventId":3000}
At C:\Data\az_permissions.ps1:21 char:13
+ $Reports = (Invoke-RestMethod -Uri $Uri -Headers $Header -Method POST ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Im not sure how to move forward. I'd appreciate any help.
Thanks & regards.