how to pass search parameters to a POST /rest/api/2/search call?

Deleted user December 7, 2017

The docs on /search call here:

https://docs.atlassian.com/software/jira/docs/api/REST/1000.1568.0/#api/2/search-searchUsingSearchRequest

define a schema as:

{ 
"
id": "https://docs.atlassian.com/jira/REST/schema/search-request#",
"
title": "Search Request",
"
type": "object",
"
properties": {
"jql": {
"type": "string" },
"startAt": {
"type": "integer"
},
"maxResults": {
"type": "integer"
},
"fields": {
"type": "array",
"items": {
"type": "string"
}
},
"validateQuery": { "type": "string" },
"properties": {
"type": "array",
"items": {
"type": "string"
}
},
"fieldsByKeys": {
"type": "boolean"
}
}
,
"
additionalProperties": false,
"
required": [
"fieldsByKeys"
]
}

 

On a GET request I would the the issuetype = Epic with something like:

/rest/api/2/search?jql=project%3D%22Project%20Name%22%20AND%20issuetype%3D%22Epic%22

 

How would I get the same result for the POST request?

 

 

 

1 answer

1 accepted

2 votes
Answer accepted
Timothy
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.
December 7, 2017

The documentation provides an example JSON body for the POST request:

{ "jql": "project = HSP", "startAt": 0, "maxResults": 15, "fields": [ "summary", "status", "assignee" ], "fieldsByKeys": false }

The value for JQL should be the actual JQL query (escaped and all).

Deleted user December 7, 2017

@Timothy, thank you for your reply. I had, in fact, already found that out.

Ashwani Garg November 23, 2021

In Laravel,

$json_body = [
"jql" => "project = XYZ",
"startAt" => 0,
"maxResults" => 20,
"fields" => [
"summary",
// "status",
// "assignee",
],
"fieldsByKeys" => false
];
$url = $jira_creds->thirdparty_baseurl.'/rest/api/3/search';
$response = Http::withBasicAuth($jira_creds->admin_username, $jira_creds->admin_password)->post($url, $json_body);
return response()->json($response->json());

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events