I am trying to publish a comment to the PR from the sample output file as the comment body. I had difficulties in preserving the human readable format in the body as it was printing it as one line. Now I think I made it to work but still the Invoke-WebRequest is failing with "innerException":null,"message":"Value cannot be null".
I can see that content is formatted correctly in $body but still null message is the error. What am I doing wrong here?
$JsonContent = Get-Content .\temp.output -Raw
$bodyFromJson = @{"comments"=@{"parrentCommentId"=0;"comment"=$JsonContent;"commentType"="1"};"properties"=@{"Microsoft.TeamFoundation.Discussion.SupportsMarkdown"=@{"type"="System.Int32";"value"="1"};"status"="1"}}
$body = $bodyFromJson | ConvertTo-Json -Depth 100
$uri = "https://dev.azure.com/uri"
$headers = @{
"Content-Type" = "application/json"
"Authorization" = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
Invoke-WebRequest -Uri $Uri -Method Post -Headers $headers -Body $body
Now I am getting the below error
temp.output content is below
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Update will perform the following actions:
# Resource ABC will be updated in-place
~ resource “resource_name” {
endpoint_name = “ABC”
endpoint_type = “xyz”
priority = 2
~ weight = 1 -> 10
custom_header {
name = “host”
value = “host.test.com”
}
}
Plan: 0 to add, 1 to change, 0 to destroy.