It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

PHP, REST API, and Multi checkboxes.

Hello,

I'm having an awful hard time getting the right JSON structor to send to JIRA via REST so that multi checkboxes are correctly set when creating a new issue in Jira.

I have data coming into an application as an JSON array and I'm then remapping it to the right custom fields in Jira and then sending it off. Ever other type of field works as expected.

A snippit from the JSON array coming into the application that contains nothing but a few checkboxes selected

array(3) {
  ["Other European"]=>
  string(14) "Other European"
  ["Middle Eastern/Latin American/African"]=>
  string(37) "Middle Eastern/Latin American/African"
  ["Other"]=>
  string(5) "Other"
}

I then add this to the JSON array that is going to JIRA using:

'customfield_11333' => ["value" => $data['Ethnicity']]

I get the error string(21) "data was not an array". I'm not really sure how I should be passing this through to Jira?

Any examples/input would be greatly appreciated.

2 answers

1 accepted

1 vote
Answer accepted

Well solved it. The correct format is of course

'customfield_11333' => [["value" => "Asian"], ["value" => "Other"]]

But required the data I had coming in to be reshaped to suit.

So I think I'm getting close with the correct syntax at least. I expected

'customfield_11339' => ["set" => ["id" => $data['Ethnicity']]],

to have worked, but still returns with data was not an array.

Hi @Chris Turner - hope you are well?

Thank you for this post ...

I am trying something similar where I do a PHP curl POST request to create an issue from a populated data block of the fields ... I tried the following (taken out all other fields) but no joy right now ...

 

{ 
"fields": {
"customfield_10199": "'.json_encode(array("value" => "a")).'"
}
}

 

To that I get:

Unexpected character ('v' (code 118)): was expecting comma to separate OBJECT entries
 at [Source: com.atlassian.plugin.connect.plugin.auth.scope.InputConsumingHttpServletRequest$1@53118af3; line: 30, column: 28]

Not sure where I am going wrong ... I have also tried adding just the ids as would for a multiselect but that's not working either.

Please advise / assist?

Thank you.

Hi, me again ... So it seems I just needed to post a reply to resolve this myself :)

The following seems to have worked:

{ 
"fields": {
"customfield_10199": '.json_encode( array ( array ( 'value' => 'a', ), array ( 'value' => 'b', ), ) ).'
}
}

 Hope it helps others out there ...

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Expose your beautifully crafted Dashboard through the Jira Service Desk Customer Portal

  A picture is worth a thousand words, especially when you're trying to find relationships and understand your data. Here, Dashboards play a vital role in gaining insights from a variety of dat...

328 views 5 4
Read article

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