JiraPS
JiraPS copied to clipboard
get-jirauser is failing against cloud instance
Description
While connected to our Jira Cloud instance, I'm unable to get-jirauser, it returns an error. Other commands, add-jiraissue, etc, have been verified as wworking
Steps To Reproduce
- Install, load JiraPS
- Set-JiraConfigServer and establish new-jirasession
- Command: get-jirauser -username "" to query all users fails:
Invoke-JiraMethod : The username or property query parameter must be provided
get-jirauser : No results when searching for user
- Command: get-user -username [email protected] for the current user, also returns:
Invoke-JiraMethod : The query parameter 'username' is not supported in GDPR strict mode.
get-jirauser : No results when searching for user [email protected]
Expected behavior
I've never been able to use this, I would assume it would return usable key pairs
Your Environment
We are using Jira Cloud
`PS C:\WINDOWS\system32> Get-Module JiraPS -ListAvailable | Select Name, Version
VERBOSE: Populating RepositorySourceLocation property for module JiraPS.
VERBOSE: Loading module from path 'C:\Users\<redacted>\Documents\WindowsPowerShell\Modules\JiraPS\2.14.6\JiraPS.psm1'.
Name Version
---- -------
JiraPS 2.14.6
PS C:\WINDOWS\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1682
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1682
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\WINDOWS\system32> `
Possible Solution
unknown
Any update on this?
I am seeing the same thing - and it seems it's because it's using v2 of the API in the module?
How to replicate:
$cred = Get-Credential
PowerShell credential request
Enter your credentials.
User: [email protected]
Password for user [email protected]: ************************
Set-JiraConfigServer -Server "https://company.atlassian.net"
New-JiraSession -Credential $cred
Username WebSession
-------- ----------
[email protected] Microsoft.PowerShell.Commands.WebRequestSession
get-jirauser -Name accountID -Credential $cred -Verbose
VERBOSE: [Get-JiraUser] Function started
VERBOSE: [Get-JiraConfigServer] Function started
VERBOSE: [Get-JiraConfigServer] Complete
VERBOSE: [Get-JiraUser] Processing [accountID]
VERBOSE: [Invoke-JiraMethod] Function started
VERBOSE: [ConvertTo-GetParameter] Making HTTP get parameter string out of a hashtable
VERBOSE:
Name Value
---- -----
username accountID
maxResults 50
VERBOSE: [Invoke-JiraMethod] Get https://company.atlassian.net/rest/api/2/user/search?username=accountID&maxResults=50
VERBOSE: [Invoke-JiraMethod] Failed to get an answer from the server
VERBOSE: [Test-ServerResponse] Checking response headers for authentication errors
VERBOSE: [Invoke-JiraMethod] Status code: BadRequest
VERBOSE: [Resolve-ErrorWebResponse] Function started
VERBOSE: [Resolve-ErrorWebResponse] Retrieved body of HTTP response for more information about the error ($responseBody)
Invoke-JiraMethod: The query parameter 'username' is not supported in GDPR strict mode.
Invoke-JiraMethod:
VERBOSE: [Resolve-ErrorWebResponse] Function ended
VERBOSE: [Invoke-JiraMethod] Function ended
Get-JiraUser: No results when searching for user accountID
VERBOSE: [Get-JiraUser] Complete
get-module jiraps
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.14.6 JiraPS {Add-JiraFilterPermission, Add-JiraGroupMember, A…
PS C:\Users\tdpocv0> $psversiontable
Name Value
---- -----
PSVersion 7.2.6
PSEdition Core
GitCommitId 7.2.6
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
There is an issue in lines 2736 and 2737 in the JiraPS.psm1 file in version 2.14.6 of the JiraPS PowerShell Module.
$searchResourceUri = "$server/rest/api/2/user/search?username={0}"
$exactResourceUri = "$server/rest/api/2/user?username={0}"
According to the Jira REST API documentation, the "username" query parameter is deprecated.
In this section of the documentation, they say you can use the query parameter named "query" to match against the displayName and emailAddress user attributes.
In my install of the JiraPS module, I have modified my JiraPS.psm1 file to use the query parameter, "query".
$searchResourceUri = "$server/rest/api/2/user/search?query={0}"
$exactResourceUri = "$server/rest/api/2/user?query={0}"
Still running into this issue, and it seems to be a problem throughout other calls as well. E.g. assigning users to issues.