%META:TOPICINFO{author="TWikiContributor" date="1442434185" format="1.1" version="$Rev$"}%
%META:TOPICPARENT{name="JiraRestPlugin"}%
---+ JIRA REST API Query

<div style="display: none;">
%SET{ response = %JIRAREST{
   action="%URLPARAM{ "action"   encode="quote" }%"
  command="%URLPARAM{ "command"  encode="quote" }%"
     data="%URLPARAM{ "data"     encode="quote" }%"
     user="%URLPARAM{ "user"     encode="quote" }%"
 password="%URLPARAM{ "password" encode="quote" }%"
}% }%
</div>
<form method="post" action="%SCRIPTURL{view}%/%WEB%/%TOPIC%">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
  <td> __Query:__ </td>
  <td></td>
  <td> %ICON{empty}%%ICON{empty}% </td>
  <td></td>
</tr>
<tr>
  <td colspan="2"> <div style="margin-top: 0.5em;"> =%<nop>SET{ response = %<nop>JIRAREST{= </div> </td>
  <td> %ICON{empty}%%ICON{empty}% </td>
  <td> __Example:__ </td>
</tr>
<tr>
  <td align="right"> =action="= </td>
  <td> <select name="action" class="twikiSelect"> <option></option> %CALCULATE{$LISTJOIN($sp, $LISTEACH(<option $IF($EXACT(%URLPARAM{ "action" encode="quote" }%, $item), selected="selected")>$item</option>, get, put, post, delete))}% </select><code>"</code> </td>
  <td></td>
  <td></td>
</tr>
<tr>
  <td align="right"> =command="= </td>
  <td> <input type="text" name="command" value="%URLPARAM{ "command" encode="entity" }%" size="80" class="twikiInputField" /> </td>
  <td> ="= </td>
  <td> =/rest/api/2/issue/TEST-1= </td>
</tr>
<tr>
  <td align="right" valign="top"> =data="= </td>
  <td> <textarea name="data" class="twikiTextarea twikiEditboxStyleMono" rows="7" style='width: 99%;'>%URLPARAM{ "data" encode="entity" }%</textarea> </td>
  <td valign="top"> ="= </td>
  <td valign="top"> ={"id":"10009"}= </td>
</tr>
<tr>
  <td align="right"> =user="= </td>
  <td> <input type="text"     name="user" value="%URLPARAM{ "user" default="%USERNAME%" encode="entity" }%" size="80" class="twikiInputField" /> </td>
  <td> ="= </td>
  <td></td>
</tr>
<tr>
  <td align="right"> =<div style="white-space: nowrap;">&nbsp;&nbsp;&nbsp;password="</div>= </td>
  <td> <input type="password" name="password" value="%URLPARAM{ "password" encode="entity" }%" size="80" class="twikiInputField" /> </td>
  <td> ="= </td>
  <td> %CALCULATE{$IF($EXACT($LEFTSTRING(%SCRIPTURL%, 5), https), <nop>, <div class="twikiAlert">See NOTE below</div>)}%</div> </td>
</tr>
<tr>
  <td> <div style="margin-bottom: 0.8em;"> =}% }%= </div> </td>
  <td></td>
  <td></td>
  <td></td>
</tr>
<tr>
  <td align="left"> __Filter:__ &nbsp; =%<nop>GET{= </td>
  <td> <input type="text" name="response" value="%URLPARAM{ "response" default="response" encode="entity" }%" size="80" class="twikiInputField" /> </td>
  <td> =}%= </td>
  <td> =response.content.fields.description= </td>
</tr>
<tr>
  <td></td><td> <div style="margin-top: 0.8em;"> <input type="submit" value="Submit" }%" class="twikiSubmit" /> </div> </td>
  <td></td>
  <td></td>
</tr>
</table>
</form>
%CALCULATE{$IF($EXACT($LEFTSTRING(%SCRIPTURL%, 5), https), <nop>, <div class="twikiAlert" style="margin-top: 1em;">NOTE: This site is not secured with TLS ([[Wikipedia:Transport_Layer_Security][Transport Layer Security]], "https:" protocol) - sending the password of a JIRA user is not recommended.</div>)}%

__Response of REST API Call:__
-----
<tt>
%GET{
  "%URLPARAM{ "response" default="response" encode="quote" }%"
}%
</tt>
-----

%H% __Help:__

   * Use this form to interactively send REST ([[Wikipedia:Representational_state_transfer][Representational state transfer]]) requests to the JIRA server.
   * The form asks for the action (REST method), command (REST API call), data (required for PUT and POST methods), user and password.
   * Omit the user and password if you want to use the default user and password specified in configure. Specifying the password is safe as long as the TWiki server enforces TLS.
   * See [[https://developer.atlassian.com/jiradev/api-reference/jira-rest-apis/jira-rest-api-tutorials][JIRA REST API Tutorials]] to get started.
   * See [[https://docs.atlassian.com/jira/REST/latest/][JIRA REST API documentation]] for details.
   * Format of [[Wikipedia:JSON][JSON]] response: ={ "code": <i>CODE</i>, "content": <i>CONTENT</i>, "error": <i>ERROR</i> }=
      * =<i>CODE</i>= - response code; example: =201=
      * =<i>CONTENT</i>= - response data, in JSON format; example: ={ "id": "59935", "key": "TEST-6952", "self": "http://jira.example.com/jira/rest/api/2/issue/59935" }=
      * =<i>ERROR</i>= - error message; empty string =""= if no error; example: ="POST '/api/2/issue/' returns code 400"=
   * The resulting JSON response can be filtered with a JSON path using SetGetPlugin#JsonObjects (plugin version 2015-03-27 or later required).

__Related:__ JiraRestPlugin, VarJIRAREST

-- TWiki:Main.PeterThoeny - 2015-06-17
