How to query for field with space in its name?

Tester October 14, 2020

I am using Python requests module to query for a bunch of tickets using JQL.

I want to limit the fields being returned by specifying the "fields" parameter. When I try to use a custom field name with space in the "fields" parameter, Jira does not return the field.

The code I am using is as below

fields = ["summary", "Branch Name"]
data = { 'jql': <jql_query>, 'startAt': 0, 'maxResults': 10, fields=fields }

# session is a Python requests object.
session.post(f"{JIRA_REST}/search", data=json.dumps(data))

The response does not include the "Branch Name" field.

Can anyone let me know how to pass in the field name so that it is returned in the response?

 

Thanks.

2 answers

0 votes
Ken Moulton Jr_ June 21, 2022

I know this is an old post, but perhaps this will help someone out in the future.

I think a lot of people are getting confused when trying to get values from custom field using SIL when a space is present in the name. It seems that the custom field value is only an string value associated with the field name itself, so you can't return the value without calling the actual field name.

I access from SIL scripts like my code below. Say my custom field is for an Employee Name, and is named as such. I would open a new browser window to the Jira Administration page, go to Issues, click on Custom Fields. locate the field you are looking for and click on the Actions cog wheel dropdown on the righthand side of the page and select, "Configure." Now look at the URL on the page it brought you to and you'll see something like, "customFieldId=10005" at the end. In this case, "customfield_10005" would be the field name.

You can access it like:

 

//this gets the custom field value from issue bh-01

string key = "bh-01" 

string empName = %key%.customfield_10005;

0 votes
mfabris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 14, 2020

It seems you are querying through the API so I would try to replace spaces with "%20".

Tester October 15, 2020

I tried that and that does not seem to help.

mfabris
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 15, 2020

what about double quoting the field name, like "'branch name'"

Tester October 15, 2020

Sadly that didn't help either.

I have tried it the following ways now:

fields = ["summary", '\"Branch Name\"']

And

fields = ["summary", "Branch%20Name"]

 

Tester October 15, 2020

Strangely using Branch Name in JQL query over REST API works:

"jql": "project = PROJECTNAME AND status != Closed AND \"Branch Name\" ~ \”branch_name\””

Suggest an answer

Log in or Sign up to answer