Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,549
Community Members
 
Community Events
165
Community Groups

Create Issue with customfield in Golang

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

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,
},
}
Try this:
Example:

customfield_11882 := tcontainer.NewMarshalMap()
customfield_11882["customfield_11882"] = map[string]interface{}{
"id": "123",
}
0 votes

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you