Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-jirauser is failing against cloud instance #465

Open
tsimons-mlmic opened this issue Oct 17, 2022 · 3 comments
Open

get-jirauser is failing against cloud instance #465

tsimons-mlmic opened this issue Oct 17, 2022 · 3 comments

Comments

@tsimons-mlmic
Copy link

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

  1. Install, load JiraPS
  2. Set-JiraConfigServer and establish new-jirasession
  3. 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 
  1. Command: get-user -username jane@domain.com 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 jane@domain.com

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

@Ayanmullick
Copy link

Any update on this?

@cjvanderlinden
Copy link

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@domain.com
Password for user email@domain.com: ************************
Set-JiraConfigServer -Server "https://company.atlassian.net"
New-JiraSession -Credential $cred

Username               WebSession
--------               ----------
email@domain.com 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

@grmn46
Copy link

grmn46 commented Aug 29, 2023

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}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants