Cannot assign issue to a user using Set-JiraIssue
Description
Assigning JIRA issues to a user with Set-JiraIssue suddenly stopped working.
Steps To Reproduce
- start a new session with
New-JiraSession - Execute
(Get-JiraIssue Issue-123) | Set-JiraIssue -Assignee (Get-JiraUser)
- The error is
Invoke-JiraMethod : Can not deserialize instance of java.lang.String out of START_ARRAY token
at [Source: org.apache.catalina.connector.CoyoteInputStream@184681e6; line: 2, column: 5] (through reference chain: com.atlassian.jira.rest.v2.issue.UserBean["name"])
At C:\Program Files\WindowsPowerShell\Modules\jiraps\2.8.6\Public\Set-JiraIssue.ps1:206 char:21
+ Invoke-JiraMethod @parameter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
+ FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod
Expected behavior
Up to recently this was assigning the issue to the signed user. Changing (Get-JiraUser) to a username string doesn't solve it.
Your Environment
JiraPS 2.8.6 PSVersion 5.1.16299.785
Get-JiraUser having validation attribute [ValidateNotNullOrEmpty()] Weird but there is no any error when running this command without parameters
-
Running the command without parameters should return the information about the user that is logged on. As defined in the docs.
-
The output of
Get-JiraUseris currently not suitable forSet-JiraIssue. This was already reported in #200 . You can add a(Get-JiraUser).Nameto work around it for now
I don't think this is a duplicat @lipkau. I have included (Get-JiraUser) in the example so I don't have to show my username, but it fails with the same exception regardless if you use -Assignee (Get-JiraUser), -Assignee (Get-JiraUser).Name or if you simply pass a string representing the user like so -Assignee myusername. So my problem, and this issue #320 is not about the Get-JiraUser but rather the Set-JiraIssue command.
I am unable to replicate the behavior you described:

Please show how you are running these commands and the output of them.
I too get this problem; if I run the commands as you have lipkau, I get
Invoke-JiraMethod : Can not deserialize instance of java.lang.String out of START_ARRAY token
at [Source: org.apache.catalina.connector.CoyoteInputStream@2dd22d10; line: 2, column: 5] (through reference chain: com.atlassian.jira.rest.v2.issue.UserBean["name"])
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.9.0\JiraPS.psm1:5335 char:21
+ Invoke-JiraMethod @parameter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
+ FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod`
Please show me the payload of $Body and $splatParameters | Out-String when you run the command with -debug when you see this message:
https://github.com/AtlassianPS/JiraPS/blob/a0e29a616fda283531d8d127dc031dc2efd9b5fd/JiraPS/Public/Invoke-JiraMethod.ps1#L157
@lipkau is that what you need?
Almost.
on the last message of the first screenshot, enter s and hit enter
then you can see the content of the local variables. such as $Body
I'll do it tomorrow
On Tue, 8 Jan 2019, 11:58 Oliver Lipkau <[email protected] wrote:
Almost. on the last message of the first screenshot, enter s and hit enter then you can see the content of the local variables. such as $Body
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AtlassianPS/JiraPS/issues/320#issuecomment-452273743, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHYMEBt5eNV1NxCC6MaoQp1C2GGQ_pkks5vBIftgaJpZM4Y708H .
I have noticed two more things this morning when running the command with the -Debug option.
First of all it fails only for some of the users, specifically so far I have only noticed that it fails only for my user, for other users I tried it works.
During execution of the Set-JiraIssue a call is made to rest/api/latest/user/search? and then 3 different calls to rest/api/2/user passing 3 different user names: mine and two other usernames that start with exact my username + and extra character at the end.
So I tried Get-JiraUser -UserName <myusername> and I got the same behaviour - 3 users not 1.
This behavior is know (#49) and already planned to changed (#306). But as it's a breaking change, it will only be released with v3.0.
for now you will have to manage with something like
Get-JiraUser -UserName <myusername> | Where name -eq <myusername>
Please have a look at this merge request. It fixes the issue without breaking changes.
I have a unit test to cover the -Exact option and modified one to be more explicit how the Get-JiraUser should work when the -Exact is not used. I have also updated the Get-JiraUser documentations.