I'm trying to set the areas that are associated with a team on a TFS 2017 on-premise server using the rest API and powershell.
When I try to invoke my URI
as explained in the API example with a json package, I get the following error return:
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Value cannot be null. \r\nParameter name: patch","typeName":"System.ArgumentNullException, mscorlib, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "typeKey":"ArgumentNullException","errorCode":0,"eventId":0} + ... $result = Invoke-RestMethod -Method Patch -Uri $setTeamAreaPathUri ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommandI could really use som guidance as to what I should look for. I've verified my Json package and it should be well-formed.
{ "defaultValue": "TeamProject\\Area1", "Values": [ { "value": "Area2\\Area21\\Area211", "includeChildren": false }, { "value": "Area3\\Area31\\Area311", "includeChildren": false } ] }
Update
I'm invoking the above URI with the powershell Invoke-RestMethod cmdlet
Invoke-RestMethod -Method Patch -Uri $setTeamAreaPathUri -UseDefaultCredentials -Body $json -ContentType "application/json"
Where $setTeamAreaPathUri
corresponds to the above http URI. Should I be using post
as my webrequest method as opposed to patch?
I'm perfectly able to get a response from the same URI using a get request. However, unable to alter the existing team areas using the patch method :-(
Update 2
This seems related to the Scandinavian chars 'æøå' being included in the area path. If I exclude all the area paths which include either æ,ø or å, I get no error. That wasn't obvious from my example... sorry! Is there a way to parse in the json so the TFS server won't break on it? Or is this because of me lacking profiency in powershell rest api invoking?
\\Area2
instead ofArea2\\Area21\\Area211
– PatrickLu-MSFT