diff --git a/README.md b/README.md index f9a92c9..fc9c869 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,57 @@ func main() { } ``` +### Create an issue + +Example how to create an issue. + +```go +package main + +import ( + "fmt" + "github.com/andygrunwald/go-jira" +) + +func main() { + jiraClient, err := jira.NewClient(nil, "https://your.jira-instance.com/") + if err != nil { + panic(err) + } + + res, err := jiraClient.Authentication.AcquireSessionCookie("username", "password") + if err != nil || res == false { + fmt.Printf("Result: %v\n", res) + panic(err) + } + + i := jira.Issue{ + Fields: &jira.IssueFields{ + Assignee: &jira.User{ + Name: "myuser", + }, + Reporter: &jira.User{ + Name: "youruser", + }, + Description: "Test Issue", + Type: jira.IssueType{ + ID: "60", + }, + Project: jira.Project{ + Name: "PROJ1", + }, + Summary: "Just a demo issue", + }, + } + issue, _, err := jiraClient.Issue.Create(&i) + if err != nil { + panic(err) + } + + fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary) +} +``` + ### Call a not implemented API endpoint Not all API endpoints of the JIRA API are implemented into *go-jira*.