Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Rest api auth error

Diana Liang
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 25, 2020

Hi, 

I'm trying to use powershell to do a rest api call to my jira cloud software to get an issue and I keep getting 403 forbidden error.  I've created an api key using: https://confluence.atlassian.com/cloud/api-tokens-938839638.html

 

Can someone give me some pointers please?

 

here is my request body:

 

$url="https://my-domain/rest/agile/1.0/issue/issueKey-1"
$username = "user@company.com";
$password = ConvertTo-SecureString –String "apikey" –AsPlainText -Force
$credential = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $username, $password
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))


$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", 'application/json')
$headers.Add("Content-type", 'application/json')
$headers.Add("Authorization", "Basic $base64AuthInfo")

Invoke-WebRequest -Method GET -Uri $url -Headers $headers -Credential $credential 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events