I am trying to use Powershell to connect Jira REST API and find a way to add few hundreds users to their groups.
First thing, i am trying to get accountId for users and i run a simple command:
GET /rest/api/3/groupuserpicker?query=user@domain.ext
in powershell this command failed with
Invoke-WebRequest : The remote server returned an error: (403) Forbidden.
but in the very same PS window this very same command works with CURL
What am i missing with PS? Does PS works with API token or do i need to do some other kind of authentication?
Thanks.
In PS, Invoke-WebRequest and Invoke-RestMethod support all of Jira's authentication methods like basic or token.
Just note that they are both sensitive to self-signed SSL certificates whereas curl isn't. Self-signed SSL certs are common with companies that have their own Jira Server and don't want / need to pay for 'real' certification from a certifying entity.
Hi @alex.kaushansky ,
I had this issue in the past, it seems that PS curl has some sort of a symbolic link to Invoke-WebRequest , and you need to include the header in a different way.
I couldn't find a way to do it in a single command, and I got this from this reddit
$Uri = "https://jira.atlassian.com/rest/api/3/groupuserpicker?query=user@domain.ext"
$Username = "username"
$Password = "apitoken"
$Headers = @{ Authorization = "Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $Username,$Password))) }
curl -Uri $Uri -Headers $Headers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.