0
votes

I'm currently trying to get worklogs from jira through java. I'm reading the documentation, about it(https://developer.atlassian.com/cloud/jira/platform/rest/#api/2/issue-createIssue) but i simply can't find some basic information like:

How do i start using that api with java ? Did i have to add something to my pom.xml ? If yes, what dependency ?

For my task(get worklogs), it's better use the java api or the rest API ?

Any of you guys can send me a light, recommend me a book or article about it or something ?

Thx in advance guys.

3

3 Answers

1
votes

If its help you, I give you link to my repo on git, there is program to load scenario test to Jira with Zephyr. There is two simple endpoints, to send post method. Github My pom:

<dependencies>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
        </dependency>
        <dependency>
            <groupId>javax.json</groupId>
            <artifactId>javax.json-api</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.json</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
    </dependencies>
0
votes

You can use JIRA's internal Java API, for example, with Groovy scripts via ScriptRunner plugin for JIRA.

You should import ComponentAccessor to get basic JIRA helper classes for the rest of logic.

Here is a Groovy script snippet to get all Worklog objects for a given issue:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.worklog.WorklogManager

worklogManager = ComponentAccessor.getWorklogManager()

def issueWorklogItems = worklogManager.getByIssue(issue)
0
votes

If you want to read/modify Jira issue from an external code then you can use Jira Rest APIs. Following links will be helpful to understand fetching/updating worklog details for an jira issue,

To get all work logs for an Jira issue, https://docs.atlassian.com/software/jira/docs/api/REST/8.0.2/#api/2/issue-getIssueWorklog

TO fetch specific worklog for an Jira issue, https://docs.atlassian.com/software/jira/docs/api/REST/8.0.2/#api/2/issue-getIssueWorklog