Posts

Showing posts from January, 2022

Extract user details into Excel from JIRA API in Powershell

Function Get-JIRAExtract { Param( [Parameter( Mandatory=$true, HelpMessage="JIRA id of the user")] [string]$assigneeId, [Parameter( Mandatory=$true, HelpMessage="Name of user.")] [string]$assigneeName, [Parameter( Mandatory=$false, HelpMessage="Target Folder.")] [string]$targetFolder = "c:\temp2" ) try { $token = "xxx" $pair = "fname.lname@company.com:$token" $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $base64 = [System.Convert]::ToBase64String($bytes) $basicAuthValue = "Basic $base64" $headers = @{ Authorization = $basicAuthValue } $url = "https://mycompany.atlassian.net/rest/api/3/search?maxResults=1000&jql=assignee%20in%20($assigneeId)AND created >= -24w AND status in ('Complete', 'In Progress', 'Resolved', 'Closed')" Write-Host "Call url $url" $json = Invoke-RestMethod -Uri $url -Method Get -Headers $headers

How can I call a JIRA api through Powershell?

 Navigate to https://id.atlassian.com/manage-profile/security/api-tokens and create an API token Then use the following code: $pair = "me@example.com:<My token here>" $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $base64 = [System.Convert]::ToBase64String($bytes) $basicAuthValue = "Basic $base64" $headers = @{ Authorization = $basicAuthValue } $json = Invoke-RestMethod -Uri "https://<mydomain>.atlassian.net/rest/api/3/search?jql= <jql here>" -Method Get -Headers $headers