I've been struggeling all day trying to make a script that changes the value of wiql.
After som debugging and testing I found out that it's actually the wiql that fails, even tho I get it from Azure Devops rest api.
select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags] from WorkItems where [System.TeamProject] = @project and [System.WorkItemType] = 'User Story' and [System.AreaPath] under 'error\wrong\folder' and [System.CreatedDate] <= '2022-12-16T00:00:00.0000000' and ([System.IterationPath] under ' folder\folder' or [System.IterationPath] under 'folder\folder')
It fails at "and [System.AreaPath] under 'error\wrong\folder' "
I removed one and one line and after I remove this I only got select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags] from WorkItems where [System.TeamProject] = @project and [System.WorkItemType] = 'User Story' it works.
Else I just get
Invoke-RestMethod : {"count":1,"value":{"Message":"Bad JSON escape sequence: \\S. Path 'wiql', line 2, position 245.\r\nUnexpected character encountered while parsing value: A. Path 'wiql', line 2, position 245.\r\n"}}
At line:1 char:13
+ $response = Invoke-RestMethod -Method Patch -Uri $testurl -Body $body ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Help`?
Tried every combo but cant get it to work