go-jira: IssueUpdate -- Issue error occured: Request failed. Please analyze the request body for more details. Status code: 400

I successfully connected to our JIRA instance and pulled in the details of an issue. I am trying to just add a label to an existing issue using IssueUpdate. I couldn’t find a good example. I did drill into the code (issue.go | UpdateIssue ) and see the JIRA link (https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue)

Here is the code I am using:

package main

import ( “fmt” “github.com/andygrunwald/go-jira” )

func main() {

base := "https://<ourJIRAserver>"
tp :=  jira.BasicAuthTransport {
	Username: "<username>",
	Password: "<token>",
}

jiraClient, err := jira.NewClient(tp.Client(), base)
if err != nil {
	fmt.Println("An error occured: ", err.Error())		
}

l := make(map[string]interface{})
l["update"] = `{ "update": { "labels": [ { "add": "cjt_test_label" } ] } }`
_, err = jiraClient.Issue.UpdateIssue("BLAH-3001",l)
if err != nil {
	fmt.Println("Issue error occured: ", err.Error())
}

}

I receive the following error every time Issue error occured: Request failed. Please analyze the request body for more details. Status code: 400

My JIRA system account has administrator privileges.

Could you give me a good example or assist me if there is a bug in IssueUpdate pertaining to labels?

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 17 (11 by maintainers)

Most upvoted comments

Thanks @ghostsquad, do you think it makes sense to add this to the README as troubleshooting?

@andygrunwald I think the error should be useful. 😉

@carljthompson you are ignoring the response here:

_, err = jiraClient.Issue.UpdateIssue("BLAH-3001",l)

that _ is the response. Read the body to get more information.