How to resolve the 500 error when importing bulk custom fields?

I am trying to run the curl command to import bulk custom fields from my command line.

The command looks like below:

curl -u <username>:<password> "https://<JIRA url>/rest/scriptrunner/latest/canned/com.onresolve.scriptrunner.canned.jira.admin.BulkImportCustomFieldValues" -H "X-Atlassian-token: no-check" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" --data "@add-opt.json"

contents of add-opt.json:

scriptParams={
"FIELD_FCS":"Default Configuration Scheme for samplelist2",
"FIELD_IMPORT_VALUES":"option1",
"canned-script":"com.onresolve.scriptrunner.canned.jira.admin.BulkImportCustomFieldValues"
}

I am getting the following error:

{"message":"For input string: \"Default Configuration Scheme for samplelist2\"",
"status-code":500,"stack-trace":"java.lang.NumberFormatException: For input stri
ng: \"Default Configuration Scheme for samplelist2\"\r\n\tat com.onresolve.scrip
trunner.canned.jira.admin.BulkImportCustomFieldValues.getSchemeFromParams(BulkIm
portCustomFieldValues.groovy:83)\r\n\tat com.onresolve.scriptrunner.canned.jira.
admin.BulkImportCustomFieldValues.doValidate(BulkImportCustomFieldValues.groovy:
68)\r\n"}

Please help in figuring out where I am going wrong.

Thank you

2 answers

1 accepted

This widget could not be displayed.

Got it solved by giving the context Id of the custom field but not the field configuration scheme ID.

Thank  you Nick for helping me resolving it.

This widget could not be displayed.

Field_FCS expects the ID of the custom field, not a random string (that doesn't even look like a field name).

If your field is called "Fred", go to the list of custom fields and find it, and click on an edit or configure link.  You should find the url contains the id - either as ...=customfield_10045... or ...id=10045...  You just need the number part of that.

When I put custom field ID in the Field_FCS ,I get the below error:

{"errorMessages":[],"flushedErrorMessages":[],"scriptRunResult":null,"errors":{"

FIELD_FCS":"No field config scheme with this ID found, or you have not selected
one."}}

 

scriptParams={
"FIELD_FCS": "10501",
"FIELD_IMPORT_VALUES": "drake\ngaga",
"canned-script":"com.onresolve.scriptrunner.canned.jira.admin.BulkImportCustomFieldValues"
}

I'm really sorry, I was working on something related and mixed that up with what I read here.  I've misread your code totally. 

You need the FCS to be the ID of the field configuration scheme, not the field.  You originally were halfway there with the name of the config scheme, but you needed to replace it with the id of the config scheme.  My misdirection to the field is totally wrong.

To get the id of the FCS, it's similar - go to the list of field configuration schemes, find the one in use for the project you're importing into and find one of the edit links - that again should give you an ...id=10234... type link

 

Thank you Nick for the quick response. I have created a field configuration scheme and associated with a project and substituted "field_fcs" with field configuration scheme id=10000.It throws the follwoing error:

{"message":"No custom field for issuetype. This should not happen. Data is likel
y to be corrupt.","status-code":500,"stack-trace":"com.atlassian.jira.exception.
DataAccessException: No custom field for issuetype. This should not happen. Data
is likely to be corrupt.\r\n\tat com.atlassian.jira.issue.fields.config.FieldCo
nfigImpl.getCustomField(FieldConfigImpl.java:56)\r\n\tat com.atlassian.jira.issu
e.fields.config.FieldConfig$getCustomField.call(Unknown Source)\r\n\tat com.onre
solve.scriptrunner.canned.jira.admin.BulkImportCustomFieldValues.doScript(BulkIm
portCustomFieldValues.groovy:96)\r\n\tat com.onresolve.scriptrunner.canned.jira.
admin.BulkImportCustomFieldValues.doScript(BulkImportCustomFieldValues.groovy)\r
\n"}

Ok, great.  The problem now is that your field does not exist, or if it does, it is not valid for the project/issuetype you are trying to import into. 

Check that

  • the field configuration does not hide the field
  • the field exists on the right screen(s)
  • the field context makes the field valid for the project/issuetype

A simple trick to help you with this - go to the project and try to create an issue.  You will find that the field is not offered to you.  Look towards the top right for the "where's my field" link and try that.  It should guide you through getting the field on to your screen.

I have associated my custom field to "TEST:Scrum Default Issue Screen"  and I see my custom field when I open a create issue window for the corresponding project TEST.

Ok, that suggests that you're trying to add your data into another project then.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

28 views 3 4
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you