Bulk import custom field values via PHP cURL Edited

I'm trying to json_encode the following PHP array while following the bulk import custom field values example.

$values = 'AAA\nBBB\nCCC';
$data = array(
'FIELD_FCS' => $contextId,
'FIELD_IMPORT_VALUES' => $values,
'canned-script' => 'com.onresolve.scriptrunner.canned.jira.admin.BulkImportCustomFieldValues'
);
$data = 'scriptParams='.json_encode($data, JSON_HEX_AMP | JSON_HEX_APOS); //the options will be useful when I use real values

The $values is formatted to have each value delimited by a slash. This format is required to use the API. When I try to json_encode the $data array and send it to the API, it simply adds 1 dropdown option of AAA\nBBB\nCCC, instead of creating 3 separate options.

I'm not sure how to force it to create 3 values instead of just 1. I tried increasing and decreasing the number of slashes, but to no avail.

1 answer

1 accepted

0 votes
Accepted answer

Nvm, I just realized that those are newline characters, not slashes, that delimit the values. But I did have to strip one of the slashes from the json_encoded result to make it work.

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

3,293 views 8 7
View question

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