Skip to content

Instantly share code, notes, and snippets.

@antekresic
Created July 22, 2016 14:02
Show Gist options
  • Save antekresic/4dda591c415d4a9dac5179efd1f7fd96 to your computer and use it in GitHub Desktop.
Save antekresic/4dda591c415d4a9dac5179efd1f7fd96 to your computer and use it in GitHub Desktop.
PostAttachment issue
package main
import (
"fmt"
"os"
"github.com/andygrunwald/go-jira"
)
func main() {
jiraClient, err := jira.NewClient(nil, "https://baseurl/")
if err != nil {
panic(err)
}
res, err := jiraClient.Authentication.AcquireSessionCookie("username", "password")
if err != nil || res == false {
panic(err)
}
r, err := os.Open("/tmp/uploadfile.txt")
if err != nil {
panic(err)
}
_, _, err = jiraClient.Issue.PostAttachment("issueKey", r, "attachfileexample.txt")
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment