Forums

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

Powershell Connect By Using A Token

murat tasova
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!
September 16, 2021

Hi there,

 I  would like to connect with Powershell to our Jira Cloud environment.

Authentication by using a Token instead of username and password.

So thought that shouldn't be difficult

One of the syntax I tried was: 

$Headers = @{
Authorization = 'Bearer'
Token = $token
}

Invoke-WebRequest -Uri 'https://transdev-nl.atlassian.net/rest/api/2/search?jql=project = CIT AND issuetype = "JIRA Request" AND (created >= startOfDay(-30d) OR updated >= startOfDay(-30d))' -Headers $Headers

 

But the system sas no! :)
or 
Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
At line:7 char:1
+ Invoke-WebRequest -Uri 'https://transdev-nl.atlassian.net/rest/api/2/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

 

Guys can someone help me with getting the correct syntax to make this work.  

 

Kind regards, 

 

Murat

 

 

1 answer

1 accepted

1 vote
Answer accepted
Ajay _view26_
Community Champion
September 16, 2021

Hi @murat tasova 

 

Can you have a look at the discussion here ? Seems like you would need to have 2FA enabled. Also https://atlassianps.org/ seems to be a great way to get started ðŸ˜ƒ

Cheers

Ajay

murat tasova
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!
September 17, 2021

Thanks Ajay

That was usefull information. Login part is working. 

Now I have to learn more about how to write query's to get the needed information out of jira.

 

Thanks again and take care of your self. 

Suggest an answer

Log in or Sign up to answer