2

I've been building my REST query by using this reference: https://docs.atlassian.com/jira/REST/latest/#d2e2713

What I've managed so far: I get it to return JSON for me based on the JQL in the URL.

The problem I get: When I tell it what specific fields I want using the fields parameter, it seems to choke on the first custom field in the list (which also happens to have a space in its name).

The question: Does anyone know which of these two things is causing a problem, and how to solve it?

Specific detail:

Here's the URL I throw at Jira:

https://jira.mycorp.com/rest/api/latest/search?jql=project=PDEV+AND+type+in+(%22IA/E%22)+AND+createdDate+%3E=+2015-03-15&fields=assignee,status,resolution,%22DM%20Number%22,%22salesforce%20dd%20id%22

The response I get from Jira starts out like the below and continues for about a whole screen... but only returns the first three fields (assignee, status, resolution). I've figured out that the field names are case sensitive so I've tried different case schemes for the first custom field (the one you see in my example is how Jira renders the field name when you browse to the issue).

{
    "expand":"schema,names",
    "startAt":0,
    "maxResults":50,
    "total":17,
    "issues":    [
{       "expand":"editmeta,renderedFields,transitions,changelog,operations",
        "id":"769468",
        "self":"https://jira.mycorp.com/rest/api...

Maybe it will help to mention that my intent is to write a python script that will use REST to do issue searches like this so I can store it in a Python dict and do further processing on it. For now, I'm just telling Chrome to take me to the URL and reading the JSON it gets back.

1
  • Okay so now I've discovered jira python (jira-python.readthedocs.org/en/latest) ... Yesterday it took me 2 hours to figure out how to construct the REST URL so I get a coherent response from Jira, today I get to the same point in about 20 minutes with jira-rest. So far, so awesome. But I'm stuck at the same point - how do I make it give me custom fields, where my field names contain spaces?
    – Johan
    Mar 27, 2015 at 10:56

1 Answer 1

4

I found the last part of this puzzle here: https://answers.atlassian.com/questions/102822/how-can-i-find-the-id-of-a-custom-field-in-jira-5

Essentially, in the REST API you need to refer to custom fields by their ID, not their name - since the name is not necessarily unique in the Jira instance. To get a list of field names, execute http://localhost/rest/api/2/field and it will come back with a full list of custom fields including their IDs. The IDs take the form: customfield_16090.

So your fields parameter might take this form: fields='assignee,status,resolution,customfield_16090,customfield_16001'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.