AtlassianPS / JiraPS

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

Get-JiraVersion -project wrong address #327

Open dimertis opened 5 years ago

dimertis commented 5 years ago

Description

get-jiraversion -project send request error (API JIRA)

Steps To Reproduce

PS C:\test> Get-JiraVersion -Project NA -Debug
DEBUG: [Get-JiraConfigServer] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraConfigServer] PSBoundParameters: 
Key         Value
---         -----
ErrorAction  Stop

DEBUG: [Get-JiraVersion] ParameterSetName: byProject
DEBUG: [Get-JiraVersion] PSBoundParameters: 
Key     Value
---     -----
Project {NA} 
Debug   True 

DEBUG: [Get-JiraVersion] Processing $_project [NA]
DEBUG: [Get-JiraConfigServer] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraConfigServer] PSBoundParameters: 
Key         Value
---         -----
ErrorAction  Stop

DEBUG: [Get-JiraProject] ParameterSetName: _Search
DEBUG: [Get-JiraProject] PSBoundParameters: 
Key        Value                                    
---        -----                                    
Project    {NA}                                     
Credential System.Management.Automation.PSCredential

DEBUG: [Get-JiraProject] Processing $_project [NA]
DEBUG: [Get-JiraProject] 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/rest/api/latest/project/NA?expand=description,lead,issueTypes,url,projectKeys   

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/rest/api/latest/project/NA?expand=description,lead,issueTypes,url,projectKeys&maxResults=25        
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-JiraProject] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraUser] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [ConvertTo-JiraIssueType] Converting $InputObject to custom object
DEBUG: [Get-JiraVersion] Invoking JiraMethod with $parameter
DEBUG: [Invoke-JiraMethod] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-JiraMethod] PSBoundParameters: 
Key               Value                                          
---               -----                                          
OutputType        JiraVersion                                    
Skip              0                                              
Paging            True                                           
Credential        System.Management.Automation.PSCredential      
Method            Get                                            
URI               https://jira/rest/api/latest/project/NA/version 
GetParameter      {orderBy, maxResults}                          
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/rest/api/latest/project/NA/version?orderBy=name&maxResults=25**
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
## Ожидаемое поведение

(404) Not Found - https://jira/rest/api/latest/project/NA/version?orderBy=name&maxResults=25 need Uri adress - https://jira/rest/api/latest/project/NA/versions?orderBy=name&maxResults=25

Expected behavior

ModuleType Version    Name     Exported Commands                                                                                                                                                                           
---------- -------    ----     ----------------                                                                                                                                                                           
Script     2.9.0      JiraPS  {Add-JiraFilterPermission, Add-JiraGroupMember, Add-JiraIssueAttachment, Add-JiraIssueComment...}  

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

Screenshots

Your Environment

Get-Module JiraPS -ListAvailable | Select Name, Version
$PSVersionTable

Possible Solution

I do not understand how the last uri(https://jira/rest/api/latest/project/NA/version?orderBy=name&maxResults=25 ) is formed

if look at the request https://jira/rest/api/latest/project/NA?expand=description,lead,issueTypes,url,projectKeys&maxResults=25 for example part of the version ....

"assigneeType":"PROJECT_LEAD","versions":[{"self":"https://jira/rest/api/latest/version/13233","id":"13233","description":"********","name":"5.06.1761.003","archived":true,"released":true,"releaseDate":"2013-03-29","userReleaseDate":"29.03.2013","projectId":10470},{"self":"https://jira/rest/api/latest/version/12788","id":"12788","description":********.","name":"5.06.1533.035","archived":true,"released":true,"releaseDate":"2012-09-28","userReleaseDate":"28.09.2012","projectId":10470},{"self":"https://jira/rest/api/latest/version/11653","id":"11653","description":"*****","name":"Permanent","archived":true,"released":true,"releaseDate":"2012-09-06","userReleaseDate":"06.09.2012","projectId":10470}....

maybe i'm wrong and not looking there

lipkau commented 5 years ago

There are 2 API endpoint for retrieving versions:

Get project versions paginated  --> GET /rest/api/2/project/{projectIdOrKey}/version
Get project versions            --> GET /rest/api/2/project/{projectIdOrKey}/versions

_source_

Get-JiraVersion uses the first in order to use paginated results

And I am unable to reproduce any kind of wrong behavior on that function: image

What version of Jira are you running?

dimertis commented 5 years ago

JIRA v6.3.10 jira

lipkau commented 5 years ago

you are running a pretty old version of jira. From what I can tell, that version was released November 2014.

This version does indeed not support the API used by the module. https://docs.atlassian.com/software/jira/docs/api/REST/6.3.10/#d2e5013

I will investigate the feasibility to support the old API as well.

nopromises

dimertis commented 5 years ago

I think this is our company problem that we use such antiquity=) Thanks for the help.