Create Issue with customfield in Golang

Jump Operations April 18, 2018

Currently having no success automatically creating Jira tickets for a specific project that has customfields, multicheckboxes. I'm attempting this in Golang with go-jira (https://github.com/andygrunwald/go-jira)

 

func main() { 

customfield_11882 := tcontainer.NewMarshalMap()
customfield_11882["value"] = "Something"
client, err := connectJira()
if err != nil {
fmt.Println("I CANT CONNECTO TO JIRA error:", err)
return
}

i := jira.Issue{
Fields: &jira.IssueFields{
Description: "Test Description",
Type: jira.IssueType{
Name: "Task",
},
Project: jira.Project{
Key: "WIT",
},
Summary: "Just a demo issue",
Unknowns: customfield_11882,
},
}
issue, response, err := client.Issue.Create(&i)
fmt.Println(response)
body, readErr := ioutil.ReadAll(response.Body)
if readErr != nil {
fmt.Println("Body error:", readErr)
return
}
fmt.Println(string(body))
if err != nil {
fmt.Println("Error: ", err)
return
}

fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
}

 

And I receive this error:

"{"errorMessages":[],"errors":{"value":"Field 'value' cannot be set. It is not on the appropriate screen, or unknown."}}
Error: Request failed. Please analyze the request body for more details. Status code: 400"

 

Does anybody have a working example in Go for customfields with multicheckboxes?
 

3 answers

1 vote
Alem Abreha March 31, 2022

This is how you can populate the values for custom fields. You can first find out what the custom field names are actually...

 

once you know what the field names are, set the values ..

customFields := tcontainer.NewMarshalMap()
customFields["customfield_10031"] = "some value ..."
customFields["customfield_10032"] = "some value ..."
customFields["customfield_10033"] = "some value ..."
and then, this is how you plug it in the jira Issue ..
jiraIssue := jira.Issue{
Fields: &jira.IssueFields{
Summary: "blah blah blah",
Project: jira.Project{
Key: "XXX",
},
Type: jira.IssueType{
Name: "some issue type",
},
Unknowns: customFields,
},
}
0 votes
Mabe Guacapiña July 29, 2021
Try this:
Example:

customfield_11882 := tcontainer.NewMarshalMap()
customfield_11882["customfield_11882"] = map[string]interface{}{
"id": "123",
}
0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 18, 2018

There's not a huge number of Golang experts here, so you might want to expand on this for a wider audience.

Could you show us the body of the request that your code builds and posts to Jira?

Suggest an answer

Log in or Sign up to answer