JiraPS
JiraPS copied to clipboard
Set-JiraUser with Property parameter fails with error 'Invoke-JiraMethod : No value found to be changed.'
Description
When using the Set-JiraUser cmdlet with the -Property parameter to set properties not named in the cmdlet (e.g. updating the user's login name), the command fails with the following output:
Invoke-JiraMethod : No value found to be changed.
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.14.7\JiraPS.psm1:5876 char:27
+ $result = Invoke-JiraMethod @parameter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
+ FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod
Steps To Reproduce
- Connect to Jira server using
Set-JiraConfigServerandNew-JiraSessionas per normal - Execute the following:
Set-JiraUser -User "bsmith" -Property @{Name="csmith"}
- Observe error
Expected behavior
Username for user bsmith should be changed to csmith
Workaround
In the same environment, crafting the REST body manually and calling Invoke-JiraMethod with the correct Uri per the below example produces the expected behavior:
$putUri = "https://jira.contoso.com/rest/api/2/user?username=bsmith"
$putBody = "{""name"": ""csmith""}"
Invoke-JiraMethod -URI $putUri -Body $changeBody -Method Put
(Note: URL of Jira server has been changed for privacy)
Your Environment
Jira Server Version: 9.12.2
Name Version
---- -------
JiraPS 2.14.7
PSVersion
PSEdition
PSCompatibleVersions
BuildVersion
CLRVersion
WSManStackVersion
PSRemotingProtocolVersion
SerializationVersion
Update: this appears to actually be a documentation issue. I realized after revisiting my workaround that passing @{Name="csmith"} in the -Property parameter will fail but @{name="csmith"} succeeds. It appears the user property names passed to the API are case sensitive (which is not specified in the official REST API docs) and do not match the capitalization used in the JiraPS outout objects or the example code given in the JiraPS documentation.