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.
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;
It seems you are querying through the API so I would try to replace spaces with "%20".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what about double quoting the field name, like "'branch name'"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sadly that didn't help either.
I have tried it the following ways now:
fields = ["summary", '\"Branch Name\"']
And
fields = ["summary", "Branch%20Name"]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Strangely using Branch Name in JQL query over REST API works:
"jql": "project = PROJECTNAME AND status != Closed AND \"Branch Name\" ~ \”branch_name\””
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.