Closed Husterknupp closed 7 years ago
Jira version: JIRA v7.2.6
to get all issues assigned to a specific user: curl -D- -u username:password -X GET -H "Content-Type: application/json" https://nameOfYourJira/rest/api/2/search?jql=assignee=username
as define in the curl command, the response is a json object
Now, that the connection works, the next step is to create a new issue via rest api.
To authenticate you simply add a parameter in the url, like in the curl command above.
@Husterknupp Do you mean we should log the new creation of a issue with a logger (I think so, but I want to be 100% sure)? Please be patient with me =)
@Bantolomeus yes, you're absolutely right. The idea was to add transparency on what our app is doing. Everytime it finds a new todo and adds a Jira issue for that todo, an interested person should be able to find information about it. Either in logs or as a REST endpoint or whatever. I found the logging option the easiest for now.
a example curl command to create a issue (documented here)
curl -u admin:admin -X POST --data @data.txt -H "Content-Type: application/json" https://jiraAdress/rest/api/2/issue/
data.txt:
{ "fields": { "project": { "id": "10000" }, "summary": "No REST for the Wicked.", "description": "Creating of an issue using ids for projects and issue types using the REST API", "issuetype": { "id": "3" } } }
The shown curl command differs from the documentation. It works as shown here.
To get the meta datas of our jira you can use this curl command:
curl -D- -u username:password -X GET -H "Content-Type: application/json" https://jira.whatEver/api/2/issue/createmeta
for assignee you can use the name shortage from gitlab (between two and four letters)
for now create a standard component and always use this standard component.
see #10 for later component setting handling
summary in data.txt is the issue title
here is a link of possible settings: https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-add-component-while-creating-an-issue-via-JIRA-REST-API/qaq-p/493660
curl command to create a new issue:
curl -u username:password -X POST --data @data.txt -H "Content-Type: application/json" https://jiraAdress/rest/api/2/issue/
data.txt:
{ "fields": { "project": { "id": "projectId" }, "summary": "title", "description": "description", "issuetype": { "id": "issueTypeId" }, "assignee": { "name": "username" }, "components": [ { "id": "componentId" } ] } }
for how to add json object to your http request, look here: http://khttp.readthedocs.io/en/latest/user/quickstart.html#more-complicated-post-requests
we need 1. Authorization and 2. content-type header
val authHeader = String(Base64.getEncoder().encode("USERNAME:PW".toByteArray()));
// addHeader("Authorization", "Basic " + auth);
// setHeader("content-type", "application/json");
for further usage the createJiraIssue method needs configurable summary and description
@Bantolomeus Code is not compiling. see my code comment.
I get this error: (default) on project jubilant-todo-tribble: The plugin pl.project13.maven:git-commit-id-plugin:2.2.1 requires Maven version [3.1.1,) -> [Help 1]
@Husterknupp Did you added this? Can you solve this? I have a lot more dependency errors
I didn't add the git-commit-id plugin lately. It's in the repo since the beginning.
Did you checkout the latest commit and tried mvn clean compile -U
?
Am 27.04.2017 um 18:38 schrieb Christian Bantel notifications@github.com<mailto:notifications@github.com>:
I get this error: (default) on project jubilant-todo-tribble: The plugin pl.project13.maven:git-commit-id-plugin:2.2.1 requires Maven version [3.1.1,) -> [Help 1]
@Husterknupphttps://github.com/Husterknupp Did you added this? Can you solve this? I have a lot more dependency errors
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Husterknupp/jubilant-todo-tribble/issues/7#issuecomment-297770589, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABNO5ir-u2u5q8_wgcnSPCqhPk26edbwks5r0MR2gaJpZM4ND6UF.
I still have the dependency problems. Thats why I can not run mvn test. I pushed the credentials class with all needed methods. @Husterknupp please test if the application runs if you pull and fill out the Return values in Credentials.kt with the correct values
I had to delete and recreate the Credentials class to be able to commit it.
@Bantolomeus sorry for this gitignore hassle. Thank you for the now compiling code. Let me double check if I have dependency problems.
In the meanwhile maybe this can be useful for you https://deutsch.lingolia.com/en/vocabulary/easily-confused-words/das-vs-dass
mvn -U clean package
outputs BUILD SUCCESS
for me. What are your dependency problems?
Implementation wise, can you please rework the issue title and the issue description to be method params? Makes sense to actually put information about a todo into the issue, right?
Done and of course it makes sense.
method params found
Programmatically create an issue