[Overview] [Operation details] [Sample configuration]
The following operation is available for working with search.Click an operation name to see details on how to use it. For a sample proxy service that illustrates how to work with search, see Sample configuration.
Operation | Description |
---|---|
searchJira | Search in JIRA using JQL. |
Following is more information about these operations.
To get an existing issue, use searchJira and specify theJQL query.
searchJira
<jira.C>
<query>{$ctx:query}</query>
<maxResults>{$ctx:maxResults}</maxResults>
<startAt>{$ctx:startAt}</startAt>
<fields>{$ctx:fields}</fields>
<validateQuery>{$ctx:validateQuery}</validateQuery>
<expand>{$ctx:expand}</expand>
</jira.searchJira>
Properties
- query: The JQL expression to use for finding issues. The query must include an ORDER BY clause. For more information, see Advanced Searching in the JIRA documentation.
- maxResults: Optional. The maximum number of issues to return, up to 1000 (default is 50).
- startAt : Optional. The 0-based index of the first issue to return (default is 0).
- fields : Specifies a comma-separated list of fields to be included in the response.
- validateQuery : Specify whether to validate the JQL query.
- expand : A comma-separated list of the parameters to expand.
Sample request
Following is a sample REST/JSON request that can be handled by the searchJira operation.
{
"username":"admin",
"password":"jira@jaffna",
"uri":"http://localhost:8080",
"query":"text~\"issue2\""
}
Sample response
Given below is a sample response for the searchJira operation.
{
"expand": "names,schema",
"startAt": 0,
"maxResults": 50,
"total": 1,
"issues": [
{
"expand": "",
"id": "10001",
"self": "http://localhost:8080/jira/rest/api/2/issue/10001",
"key": "HSP-1"
}
]
}
Related JIRA documentation
https://developer.atlassian.com/static/rest/jira/6.1.html#d2e4074
Following is a sample proxy service that illustrates how to connect to Jira with the init operation and use the searchJira operation. You can use this sample as a template for using other operations in this category.
- Create a sample proxy as below :
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="searchJira"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="username" expression="json-eval($.username)"/>
<property name="password" expression="json-eval($.password)"/>
<property name="uri" expression="json-eval($.uri)"/>
<property name="query" expression="json-eval($.query)"/>
<property name="maxResults" expression="json-eval($.maxResults)"/>
<property name="startAt" expression="json-eval($.startAt)"/>
<property name="fields" expression="json-eval($.fields)"/>
<property name="validateQuery" expression="json-eval($.validateQuery)"/>
<property name="expand" expression="json-eval($.expand)"/>
<jira.init>
<username>{$ctx:username}</username>
<password>{$ctx:password}</password>
<uri>{$ctx:uri}</uri>
</jira.init>
<jira.searchJira>
<query>{$ctx:query}</query>
<maxResults>{$ctx:maxResults}</maxResults>
<startAt>{$ctx:startAt}</startAt>
<fields>{$ctx:fields}</fields>
<validateQuery>{$ctx:validateQuery}</validateQuery>
<expand>{$ctx:expand}</expand>
</jira.searchJira>
<log level="full"/>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>
- Create a json file named searchJira.json and copy the configurations given below to it:
{
"username":"admin",
"password":"jira@jaffna",
"uri":"http://localhost:8080",
"query":"text~\"issue2\""
}
-
Replace the credentials and details with your values.
-
Execute the following curl command:
curl http://localhost:8280/services/searchJira -H "Content-Type: application/json" -d @searchJira.json
- Jira returns a json response similar to the one shown below:
{
"expand": "names,schema",
"startAt": 0,
"maxResults": 50,
"total": 1,
"issues": [
{
"expand": "",
"id": "10001",
"self": "http://localhost:8080jira/rest/api/2/issue/10001",
"key": "HSP-1"
}
]
}