Forums

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

Powershell not returning results

Jonathan Gilbert
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!
June 17, 2019

I can see from various posts, there is much discussion around Rest API with Powershell and the format of logging in. Originally we had the authorisation set to basic, but from reading a post from April 19, you can no longer use this and have to used basic_auth, along with your username and a tokencode.

When running the script below it does not give any errors, but also does not return any results, but if I was to put the url into a browser, it returns the results, any ideas?. I have remove specific detail form the script

 

#Set Login
$Jheader = @{
basic_auth=('username here', 'tokencode here')
}

#Get projects from Jira
$projects = Invoke-RestMethod -Method Get -Uri "https://MYINSTANCENAMEHERE/rest/api/2/project?expand=issueTypes" -Headers $Jheader -ContentType "application/json"

 

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 18, 2019

Hi @Jonathan Gilbert ,

Can you kindly check:

  • That you are using email-address and api-token to authenticate
  • That you don't have to use a proxy to connect to your instance
  • That you are able to authenticate the same call using the same credentials using curl. Like e.g. (mask the sensitive data like in below example):
    curl -D- -u xxxxxxx@atlassian.com:xxxxxxxxxxxxx -H "Accept: application/json" -H "Content-Type: application/json" -X GET https://xxxxxxx.atlassian.net/rest/api/2/project?expand=issueTypes

    HTTP/2 200
    server: AtlassianProxy/1.15.8.1
    vary: Accept-Encoding
    [removed]
    ....

    [{"expand":"description,lead,issueTypes,url,projectKeys,permissions","self":"https://xxxxxxxx.atlassian.net/rest/api/2/project/10301","id":"10301",.........

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events