AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
323 stars 131 forks source link

Get-JiraGroupMember. Can't get no one user in custom group #310

Closed Dreamer1cc closed 6 years ago

Dreamer1cc commented 6 years ago

Description

Command Get-JiraGroupMember don't gives out put

Steps To Reproduce

Try to use command

Get-JiraGroup -GroupName "WB_CBMT_Group"  |  Get-JiraGroupMember -PageSize 50

Result is - nothing.

Trying to use step-by-step.

  1. Get-JiraGroup -GroupName "WB_CBMT_Group" Result is OK
    Name          Size RestUrl
    ----          ---- -------
    WB_CBMT_Group   12 https://jira.some-address/rest/api/2/group?groupname=WB_CBMT_Group

Trying to Debug:

DEBUG: [Get-JiraConfigServer] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraConfigServer] PSBoundParameters:
Key         Value
---         -----
ErrorAction  Stop

DEBUG: [Get-JiraGroupMember] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraGroupMember] PSBoundParameters:
Key                Value
---                -----
PageSize              50
Debug               True
Group    {WB_CBMT_Group}

DEBUG: [Get-JiraConfigServer] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraConfigServer] PSBoundParameters:
Key         Value
---         -----
ErrorAction  Stop

DEBUG: [Get-JiraGroup] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraGroup] PSBoundParameters:
Key         Value
---         -----
GroupName   {WB_CBMT_Group}
Credential  System.Management.Automation.PSCredential
ErrorAction Stop

DEBUG: [Get-JiraGroup] Processing $group [WB_CBMT_Group]
DEBUG: [Get-JiraGroup] Invoking JiraMethod with $parameter
DEBUG: [Invoke-JiraMethod] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-JiraMethod] PSBoundParameters:
Key        Value
---        -----
Credential System.Management.Automation.PSCredential
Method     Get
URI        https://jira.some-address/rest/api/latest/group?groupname=WB_CBMT_Group

DEBUG: [Get-JiraSession] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraSession] PSBoundParameters:
Key                    Value
---                    -----
ErrorAction SilentlyContinue

DEBUG: [Invoke-JiraMethod] Invoke-WebRequest with $splatParameters:
Name                           Value
----                           -----
ErrorAction                    Stop
Headers                        {Accept-Charset, Accept}
ContentType                    application/json; charset=utf-8
Method                         Get
WebSession                     Microsoft.PowerShell.Commands.WebRequestSession
Uri                            https://jira.some-address/rest/api/latest/group?maxResults=25&groupname=WB_CBMT_Group
UseBasicParsing                True
Verbose                        False
DEBUG: [Invoke-JiraMethod] Executed WebRequest. Access $webResponse to see details
DEBUG: [Test-ServerResponse] Investigating $InputObject.Headers['X-Seraph-LoginReason']
DEBUG: [ConvertTo-JiraGroup] Converting $InputObject to custom object
DEBUG: [Get-JiraGroupMember] Processing $_group [WB_CBMT_Group]
DEBUG: [Get-JiraGroupMember] Invoking JiraMethod with $parameter

DEBUG: [Invoke-JiraMethod] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-JiraMethod] PSBoundParameters:
Key               Value
---               -----
OutputType        JiraUser
Skip              0
Paging            True
Credential        System.Management.Automation.PSCredential
Method            Get
URI               https://jira.some-address/rest/api/latest/group/member
GetParameter      {maxResults, groupname}
IncludeTotalCount False
First             18446744073709551615

DEBUG: [Get-JiraSession] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraSession] PSBoundParameters:
Key                    Value
---                    -----
ErrorAction SilentlyContinue

DEBUG: [Invoke-JiraMethod] Invoke-WebRequest with $splatParameters:
Name                           Value
----                           -----
ErrorAction                    Stop
Headers                        {Accept-Charset, Accept}
ContentType                    application/json; charset=utf-8
Method                         Get
WebSession                     Microsoft.PowerShell.Commands.WebRequestSession
Uri                            https://jira.some-address/rest/api/latest/group/member?maxResults=50&groupname=WB_CBMT_Group
UseBasicParsing                True
Verbose                        False
DEBUG: [Invoke-JiraMethod] Executed WebRequest. Access $webResponse to see details
DEBUG: [Test-ServerResponse] Investigating $InputObject.Headers['X-Seraph-LoginReason']
DEBUG: [Resolve-ErrorWebResponse] ParameterSetName: __AllParameterSets
DEBUG: [Resolve-ErrorWebResponse] PSBoundParameters:
Key        Value
---        -----
Exception  The remote server returned an error: (404) Not Found.
StatusCode NotFound
Cmdlet     System.Management.Automation.PSScriptCmdlet

DEBUG: [Resolve-ErrorWebResponse] Got the following error as $responseBody

Expected behavior

I expected to get members of this group like a Get-JiraUser

Your Environment

Name    : JiraPS
Version : 2.8.6

Name                           Value
----                           -----
PSVersion                      5.1.14409.1012
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1012
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Atlassian JIRA Project Management Software v6.4.7

lipkau commented 6 years ago

Thanks for reporting this.

Is it a cloud server or on-premise?

Dreamer1cc commented 6 years ago

It is on-premise server

lipkau commented 6 years ago

Can you check the results of this REST API in your browser (you have to have logged on before opening the URL): https://jira.some-address/rest/api/latest/group/member?maxResults=25&groupname=WB_CBMT_Group

I have only a cloud server to test with - and there it works perfectly

Dreamer1cc commented 6 years ago
<status>
<status-code>404</status-code>
<message>
null for uri: https://jira.some-address/rest/api/latest/group/member?maxResults=25&groupname=WB_CBMT_Group
</message>
</status>
Dreamer1cc commented 6 years ago

in on-side i can get users by this link: https://jira.some-address/rest/api/2/group?groupname=WB_CBMT_Group&expand=users

And what result is: https://pastebin.com/DnCEye9s

stevenyoungs commented 6 years ago

In case it helps, the query @lipkau provided https://jira.some-address/rest/api/latest/group/member?maxResults=25&groupname=WB_CBMT_Group worked correctly on our on-premise server (I had to change the group name and server address). Tested against Jira 7.5.0

Dreamer1cc commented 6 years ago

So, maybe cause of it is my Jira Server version. It's too old?

lipkau commented 6 years ago

yes. Your jira version (6.4.7) provides this information in a completely different way. v6.4.7: https://docs.atlassian.com/software/jira/docs/api/REST/6.4.7/#d2e5667 v7.12.0: https://docs.atlassian.com/software/jira/docs/api/REST/7.12.0/#api/2/group-getUsersFromGroup

I had several conversations regarding API changes from version to version. It's a very difficult topic - especially because Atlassian is so bad at writing APIs. In order to be 100% backward compatible, we would need to maintain a DB with the REST API and it's changes from version to version. For which we obviously (and unfortunately) do not have the manpower to do.

So, I am sorry to say, this action is not supported on your version of Jira with the latest version of JiraPS. I believe older versions of the module will work. Maybe a future version will be backward compatible - you can write a feature request for this function to be "smarter" - but at least for now, you have 3 options:

  1. Update Jira (easier said then done, I know - but... there is a reason why Atlassian released updates ;-) )
  2. Use an old version of JiraPS (easiest way would be to try Install-Module PSJira, which is on version 1.2.5.251)
  3. Change the code yourself, so that it supports both APIs (you need the current code for cloud servers) - and submit a PR with the changes 4. Wait for someone else to do 3.
Dreamer1cc commented 6 years ago

Ok, thank you, i think - it is not a bug. It is a feature, what this module "sometimes" working with my version