Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
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
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 29, 2021
Try this:
Example:

customfield_11882 := tcontainer.NewMarshalMap()
customfield_11882["customfield_11882"] = map[string]interface{}{
"id": "123",
}
0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
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
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events