Passing multiple components in JSON Object

Maximilian Herbert
Contributor
October 17, 2023

Hey there,

I use the ConfiForm makro in Confluence to generate a Jira Issue.

In the Macro body I defined the Object with JSON. 

But I somehow cannot pass multiple components to create the Jira Ticket... anyone has a clue what is the correct syntax / where my mistake is? I tried out multiple syntaxes but none worked so far...

The code below is my latest try.

 

 

{
"fields": {
"project": {
"id": "XXXX"
},
"summary": "Summary1",
"description": "Description1",
"issuetype": {
"id": "XXXX"
},
"components": {
"name": [
"Component1",
"Component2"
]
},
"labels": [
"Label1",
"Label2"
]
}
}  

1 answer

0 votes
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 17, 2023

Hi @Maximilian Herbert 

According to Jira documentation it goes like this

"components": [
{ "name": "Component1" },
{ "name": "Component2" }
],

Alex

Maximilian Herbert
Contributor
October 17, 2023

Hi Alex,

 

that was one of my very first tries..
But this error occures:

  • Could not prepare JSON (Expected a ',' or '}' at 316 [character 2 line 14]): '{ "fields": { "project": { "id": "XXXX" }, "summary": "XXXX", "description": "XXX", "issuetype": { "id": "XXX" }, "components": [ { "name": "Component1" "name": "Component2" } ], } }'
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 17, 2023

Please have a look more carefully at what I have suggested to do and your "error"

Like Bill Sheboy likes this
Maximilian Herbert
Contributor
October 17, 2023

That exactly is the thing:
The JSON code which generates this error looks like that:


{ "fields": { "project": { "id": "XXXX" }, "summary": "XXXX", "description": "XXX", "issuetype": { "id": "XXX" }, "components": [ { "name":"Component1" }, { "name":"Component2" } ], "labels": [ "Label1", "Label2" ] } }

 

So basically it is the same code as you commented.. I dont know why there are missing brackets in the error....

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 17, 2023

Does it shows the same error about the broken JSON?

Maximilian Herbert
Contributor
October 17, 2023

Nope. My latest code generates the broken JSON error and yours leads to the could not prepare json code....

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 17, 2023

This is a perfectly valid JSON

{ "fields": { "project": { "id": "XXXX" }, "summary": "XXXX", "description": "XXX", "issuetype": { "id": "XXX" }, "components": [ { "name":"Component1" }, { "name":"Component2" } ], "labels": [ "Label1", "Label2" ] } }

Could you share the actual configuration - page storage format? 

Bill Sheboy
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.
October 17, 2023

Hi @Maximilian Herbert 

Adding to Alex's answer...

Here is the documentation reference to check: https://confluence.atlassian.com/automation/advanced-field-editing-using-json-993924663.html

And, please check for any stray / trailing commas.  In your post about "one of my first tries" there is definitely a stray comma.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer