Query specific JIRA fields using PowerShell

I am looking to query a specific field in a JIRA ticket and pass the value to a variable (or output to a file).

Running a curl against a URL (see example below) gives me a large block out output in JSON format as expected:

curl -u username https://jira.abc.com/rest/api/2/search?jql=key=RLG-1234

 

If I use "Invoke-RestMethod" via PowerShell the output comes back in a tabular format

Invoke-RestMethod -Credential $creds -Uri https://jira.abc.com/rest/api/2/search?jql=key=RLG-1234
startAt maxResults total issues
------- ---------- ----- ------
0 		50 			0 		{}
 
GetType()
IsPublic IsSerial Name                                     BaseType                                                                                                   
-------- -------- ----                                     --------                                                                                                   
True     False    PSCustomObject                           System.Object

Piping the output of "Invoke-RestMethod" to "Get-member -MemberType NoteProperty | Get-Member -Name issues" does not give me anything.

How do I drill down to a specific field under "issues" so that I can access its value?

1 answer

This widget could not be displayed.

Add the fields you want to the rest call with an & - it's well buried in the docs, but it does work:

&fields=id,key

 

curl -u username https://jira.abc.com/rest/api/2/search?jql=key=RLG-1234&fields=id,key

Thanks! I am able to get what I want using curl and then pipe to JQ to get specific values, but since am moving to PowerShell, I would like to know how to accomplish this using Invoke-RestMethod (or any other more appropriate way)

That is invoking a REST method, and it's the only way to get the server to restrict its response to a sub-set of fields.

I'm no sure what pwoershell is doing, I don't use it.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

54 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you