Jira Cloud: Search Issues with JQL
See more Jira Examples
Use enhanced JQL search to retrieve selected issue fields across every page. Sending JQL in a JSON POST body avoids URL-length and query-encoding problems. The current endpoint uses nextPageToken; do not substitute startAt or use the deprecated /rest/api/3/search endpoint.
Results include only issues visible to the account. Recent changes can take time to appear in search. If immediate read-after-write consistency is needed, use the endpoint's reconcileIssues option with the affected numeric issue IDs, or retrieve a known issue directly. A pagination token belongs to the same query and selected fields.
The code uses an Atlassian account email and an API token without scopes with the site URL. For a scoped API token, keep Basic authentication and change baseUrl to https://api.atlassian.com/ex/jira/YOUR_CLOUD_ID. For OAuth2, use that gateway URL, omit Login/Password/BasicAuth, and set http.AuthToken to the access token. See API token authentication and OAuth2 authorization. The account must have permission for the operation; OAuth scopes do not grant additional Jira permissions.
Targets Jira Cloud. Jira Data Center has a separate REST API and may require different paths, authentication, or payloads.
Atlassian REST API documentation
Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Http
string ls_BaseUrl
oleobject loo_Url
oleobject loo_Resp
oleobject loo_Reply
oleobject loo_Request
string ls_PreviousToken
string ls_NextToken
long li_More
long li_Count
long i
li_Success = 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Http.RequireSslCertVerify = 1
loo_Http.BasicAuth = 1
// Read these credentials from private application configuration.
loo_Http.Login = "YOUR_ATLASSIAN_EMAIL"
loo_Http.Password = "YOUR_API_TOKEN"
ls_BaseUrl = "https://your-domain.atlassian.net"
loo_Http.Accept = "application/json"
loo_Url = create oleobject
li_rc = loo_Url.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")
loo_Reply = create oleobject
li_rc = loo_Reply.ConnectToNewObject("Chilkat.JsonObject")
loo_Request = create oleobject
li_rc = loo_Request.ConnectToNewObject("Chilkat.JsonObject")
// Bound the query to a project. Adapt the JQL to your permissions and needs.
loo_Request.UpdateString("jql","project = PROJECT ORDER BY key")
loo_Request.UpdateInt("maxResults",50)
loo_Request.UpdateString("fields[0]","summary")
loo_Request.UpdateString("fields[1]","status")
loo_Request.UpdateString("fields[2]","assignee")
ls_PreviousToken = ""
ls_NextToken = ""
li_More = 1
do while (li_More = 1)
loo_Url.SetString(ls_BaseUrl)
loo_Url.Append("/rest/api/3/search/jql")
li_Success = loo_Http.HttpJson("POST",loo_Url.GetAsString(),loo_Request,"application/json",loo_Resp)
if loo_Resp.StatusCode = 0 then
Write-Debug "No HTTP response was received. Check connectivity and TLS settings."
destroy loo_Http
destroy loo_Url
destroy loo_Resp
destroy loo_Reply
destroy loo_Request
return
end if
if (li_Success <> 1) OR (loo_Resp.StatusCode < 200) OR (loo_Resp.StatusCode >= 300) then
Write-Debug "Request failed. HTTP " + string(loo_Resp.StatusCode)
if loo_Resp.StatusCode = 429 then
Write-Debug "Rate limited. Retry-After: " + loo_Resp.GetHeaderField("Retry-After")
end if
// Inspect this response locally; it can contain private Jira data.
Write-Debug loo_Resp.BodyStr
destroy loo_Http
destroy loo_Url
destroy loo_Resp
destroy loo_Reply
destroy loo_Request
return
end if
li_Success = loo_Reply.Load(loo_Resp.BodyStr)
if li_Success <> 1 then
Write-Debug "Expected a JSON object in the response."
destroy loo_Http
destroy loo_Url
destroy loo_Resp
destroy loo_Reply
destroy loo_Request
return
end if
if loo_Reply.JsonTypeOf("issues") <> 4 then
Write-Debug "Expected an array: issues"
destroy loo_Http
destroy loo_Url
destroy loo_Resp
destroy loo_Reply
destroy loo_Request
return
end if
li_Count = loo_Reply.SizeOfArray("issues")
i = 0
do while (i < li_Count)
loo_Reply.I = i
Write-Debug loo_Reply.StringOf("issues[i].key") + " " + loo_Reply.StringOf("issues[i].fields.summary") + " " + loo_Reply.StringOf("issues[i].fields.status.name")
if loo_Reply.IsNullOf("issues[i].fields.assignee") <> 1 then
Write-Debug "Assignee: " + loo_Reply.StringOf("issues[i].fields.assignee.displayName")
end if
i = i + 1
loop
li_More = (loo_Reply.BoolOf("isLast") <> 1)
if li_More = 1 then
if (loo_Reply.JsonTypeOf("nextPageToken") <> 1) OR (loo_Reply.StringOfEquals("nextPageToken","",1) = 1) then
Write-Debug "Missing value: nextPageToken"
destroy loo_Http
destroy loo_Url
destroy loo_Resp
destroy loo_Reply
destroy loo_Request
return
end if
ls_NextToken = loo_Reply.StringOf("nextPageToken")
if ls_NextToken = ls_PreviousToken then
Write-Debug "Repeated pagination token; stopping."
destroy loo_Http
destroy loo_Url
destroy loo_Resp
destroy loo_Reply
destroy loo_Request
return
end if
ls_PreviousToken = ls_NextToken
loo_Request.UpdateString("nextPageToken",ls_NextToken)
end if
loop
destroy loo_Http
destroy loo_Url
destroy loo_Resp
destroy loo_Reply
destroy loo_Request