Search API Request not returning values for a field that I know has a value.

Aram Watson June 27, 2023

I have a PowerShell script that makes a POST request to a Jira server. The request body contains JQL and Fields I want returned.

 

The URL The request is being made to: 

"https://*************/rest/api/2/search"

The JQL Query :

"project = vippd and issuetype = story and duedate < 30d"

The request body: 

$requestBody = @{
       "jql" = $jqlQuery
       "fields" = @(
                "*all"
)} 

There is a lot to the script but that has to do with formatting my output but that shouldn't be important for the scope of this question. 

When looking at the raw response with a little formatting done to separate each field. I notice that there are a lot of fields that don't have any data in them, this wouldn't be alarming if they were actually empty but plenty of those fields have data if I check the issue in my browser.

Would anyone know why those fields aren't returning their data and how I can make it so that they do?

1 answer

1 accepted

1 vote
Answer accepted
Radek Dostál
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.
June 28, 2023

Well, first, check the values in

/rest/api/2/issue/<issueKeyOrId>?fields=customfield_xxx,description,etc

 

Since what you describe should not be the case, I think some examples would be useful to understand the context a bit better. Some fields may display values dynamically without an actual "storage" representation, so to speak, so I guess knowing what kind of fields you're trying to get might be one factor.

Aram Watson June 28, 2023

Here's an output from the /rest/api/2/issue API.

issue output2.PNG

After looking at all the fields used on our Jira server I noticed that we have 4 possible custom fields that could be the information I'm looking for. Developer, Developers, Developer(s) and Assigned Developer. I don't have much control over that.

What I've noticed after investigating is that The Developers custom field is the only one that will ever return anything and that is if only one Developer is present in that field.

All the other fields remain empty no matter what issue I try.

Here's the script that I'm using to call the API and get that information.

The developers Field has a field type of Multi User picker

 

# Set Jira API URL and issue key
$jiraUrl = "******/rest/api/2/issue"
$issueKey = "****"  # Replace with the actual Jira issue key
# Create and configure the HTTP request
$request = [System.Net.WebRequest]::Create("$jiraUrl/$issueKey")
$request.Headers.Add("Authorization", "Basic $base64Auth")
# Read the response content
$response = $request.GetResponse()
try {
   
# Get the response
    $response = $request.GetResponse()
   
# Read the response content
    $responseStream = $response.GetResponseStream()
    $reader = New-Object System.IO.StreamReader($responseStream)
    $responseBody = $reader.ReadToEnd()
   
# Convert the JSON response to PowerShell objects
    $responseData = $responseBody | ConvertFrom-Json
 
  # Output the issue data
    Write-Host "Issue Key: $($responseData.key)"
    Write-Host "Summary: $($responseData.fields.summary)"
    Write-Host "Description: $($responseData.fields.description)"
    Write-Host "devs: $($responseData.fields.developer)"
Write-Host "devss: $($responseData.fields.developers)"
   
# Add more fields as needed
# Replace  with the actual key of the custom field
$customField = $responseData.fields.customfield_17403 
Write-Host "Custom Field: $($customField)"
}
finally {
    # Close the response stream and dispose the objects
    if ($reader) { $reader.Close() }
    if ($responseStream) { $responseStream.Close() }
    if ($response) { $response.Close() }
}
Aram Watson June 28, 2023

After more investigation I was able to get the info out of the custom field. 

Thank you for the push in that direction. Led me down the rabbit hole that got me what I needed

Dipankar_bala
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 25, 2024

@Aram Watson  I am fetching the same issue.  Could you tell me, how you overcame this issue? I am getting the assignee field "null", where the assignee is visible in the browser.

Suggest an answer

Log in or Sign up to answer