Hi all,
I have run in to an issue with JQL in Powershell using the 'Invoke-WebRequest' commandlet. The comment I am using (below) works in Browser, and it works in Postman (with basic auth), however it consistently returns 400 Bad Request. And I'm wondering where I am going wrong.
Command:
Invoke-WebRequest -Uri 'https://site.mysite.com/issues/rest/api/2/search?jql=project%20%3D%20TEAM%20AND%20fixVersion%20%3D%20%22Version%20%To20Check%20For%22' -Credential $cred
The above command has been anonymised, but otherwise it works in browser and Postman. I've messed around with formatting thinking at various times that it might be spacing, quotation marks & other caveats. However, I have ruled out most of those.
I am sure I am missing something basic. The JQL is correct, because it is copied directly from a JIRA Url showing the report I'm seeking to ingest as data in Powershell.
Any help would be appreciate.
Thanks!
Niall.
Hey Collins,
Your REST API url is wrong
Please use https://<jira_base_url>/rest/api/2/search?jql='bla bla'
For working example please find attached code snippet
$user = 'username'
$pass = 'password'
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
}
Invoke-WebRequest -Uri 'https://<jira_base_url>/rest/api/2/search?jql=project = CIT AND issuetype = "JIRA Request" AND (created >= startOfDay(-30d) OR updated >= startOfDay(-30d))' `
-Headers $Headers
For documentation:
https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/search-search
Hope this helps
Thanks
Chander Inguva
@Niall Collins, In short:
Remove the portion of your URL that has "/issues" in it.
So go from
https://site.mysite.com/issues/rest/api/2/search?blahblahblah
to
https://site.mysite.com/rest/api/2/search?blahblahblah.
Also, you can (should, maybe?) replace that "2" with "latest".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.