Using an API call
Referencing ADF: Document builder (atlassian.com)
I have successfully set the description field as:
{ "update": { "description": [ { "set": { "version": 1, "type": "doc", "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "Hi" } ] } ] } } ] } }
I would like then update the field, adding another line that says "hello again" (not really, this is just test data). I believe swappting "set" for "add" should achieve this: Advanced field editing using JSON | Cloud automation Cloud | Atlassian Support
My attempts are failing:
{ "update": { "description": [ { "add": { "version": 1, "type": "doc", "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "Hello again" } ] } ] } } ] } }
Hello
To resolve this issue when updating the description field using the Jira REST API and ADF (Atlassian Document Format), you should avoid using "add"
as it doesn't concatenate text. Instead, you should use "set"
and reconstruct the entire document with the new content added. Here's an example:
{
"update": {
"description": [
{
"set": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{ "type": "text", "text": "Existing text" }
]
},
{
"type": "paragraph",
"content": [
{ "type": "text", "text": "Newly added text" }
]
}
]
}
}
]
}
}
Will it fail on "add" all the time then?
The end goal was to generate a table, then each update would just add another table below the first.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using "add"
doesn't work as expected for appending content like tables. The "add"
operation in the ADF format is used to append content within the same node, but it won't concatenate new structures like entire tables. If your goal is to add multiple tables below each other, you'll need to retrieve the existing content first, append the new table, and then use "set"
to update the description with the combined content.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll give you an example that might help you.
{
"update": {
"description": [
{
"set": {
"version": 1,
"type": "doc",
"content": [
{
"type": "table",
"content": [
{
"type": "tableRow",
"content": [
{ "type": "tableHeader", "content": [{ "type": "text", "text": "Header 1" }] },
{ "type": "tableHeader", "content": [{ "type": "text", "text": "Header 2" }] }
]
},
{
"type": "tableRow",
"content": [
{ "type": "tableCell", "content": [{ "type": "text", "text": "Cell 1" }] },
{ "type": "tableCell", "content": [{ "type": "text", "text": "Cell 2" }] }
]
}
]
},
{
"type": "table",
"content": [
{
"type": "tableRow",
"content": [
{ "type": "tableHeader", "content": [{ "type": "text", "text": "New Header 1" }] },
{ "type": "tableHeader", "content": [{ "type": "text", "text": "New Header 2" }] }
]
},
{
"type": "tableRow",
"content": [
{ "type": "tableCell", "content": [{ "type": "text", "text": "New Cell 1" }] },
{ "type": "tableCell", "content": [{ "type": "text", "text": "New Cell 2" }] }
]
}
]
}
]
}
}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok that makes sense.
In that case I could just bring the looping of the data to completion first then do the final 'set' once I have it all complete.
Then *if* I need to append anything I can do that read of the old data, then set the old+new.
Thanks! 🙏
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.