Atlassian, JIRA, REST

Using JIRA REST API via Restclient.

While implementing JIRA plugins, I recently had to use JIRA REST API to create and modify issues.

As I did not want to install any desktop application, I decided to use the RESTclient plug-in for Firefox.

It provides a very convenient way to deal with REST requests, and makes it possible to try out your own REST functions fast.

I however faced some problems during setting up the client, so I list here, how to do it properly, in order to avoid wasting my time at the next ocassion.

  • Install the RESTclient add-on for Firefox, from the Firefox application store
  • Start the plugin
  • Set up the request:
  • Method: POST
  • URL: http://localhost:2990/jira/rest/api/2/issue
  • Define authentication by adding a new authentication element to the request. Select basic authentication, and set username and password
  • Define content type by adding a new header element: Content-Type:application/json
  • Define user agent: User-Agent:adminIt is necessary, for avoid JIRA error message: “403 Forbidden”. If it is not defined, you get error from the REST API, and following log entry is shown in JIRA log:
    “XSRF checks failed for request”
  • Define message body
{
    "fields": {
       "project":
       { 
          "key": "TEST"
       },
       "summary": "REST ye merry gentleme.",
       "description": "Creating of an issue using project keys and issue type names using the REST API",
       "issuetype": {
          "name": "Bug"
       }
   }
}
  • Send the REST command.

For REST commands visit the JIRA documentation.

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s