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
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, that suggests that you're trying to add your data into another project then.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.