Also posted here: https://community.developer.atlassian.com/t/jira-automation-400-error-when-updating-description-field-with-adf-and-smart-values-in-put-payload/95021?u=wendyquon
Hello, wonderful people on the internet,
I’m trying to automate the synchronization of Jira issues between two Jira Cloud instances using Automation for Jira. My goal is to update an array of fields by replacing their values, and to append (not overwrite) labels. The main challenge is updating the description field, which uses Atlassian Document Format (ADF) for rich text.
What I’m Trying to Achieve:
Replace various fields on the target issue.
Append all labels from the source issue to the target issue (without overwriting existing labels). (labels part works!)
Overwrite the description field on the target issue, preserving rich text formatting (ADF).
What I’ve Tried:
{
"fields": {
"project": { "key": "SCC" },
"issuetype": { "name": "Story" },
"summary": "{{issue.summary}}",
"reporter": {
"accountId": "712020:64921a83-74ae-4d39-993a-0ffedc3a295b"
},
"customfield_10254": {
"id": "712020:64921a83-74ae-4d39-993a-0ffedc3a295b"
},
"customfield_10001": "a3e59c5c-98ec-4251-a5c4-d47ad5867302",
"parent": { "key": "SCC-1872" },
"labels": ["OWL"],
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "{{issue.description}}"
}
]
}
]
},
"customfield_10266": {
"type": "doc",
"version": 1,
"content": [
{ "type": "paragraph", "content": [ { "type": "text", "text": "{{issue.customfield_10916}}" } ] }
]
},
"customfield_10232": {
"type": "doc",
"version": 1,
"content": [
{ "type": "paragraph", "content": [ { "type": "text", "text": "{{issue.customfield_10917}}" } ] }
]
},
"customfield_10242": {
"type": "doc",
"version": 1,
"content": [
{ "type": "paragraph", "content": [ { "type": "text", "text": "{{issue.customfield_10918}}" } ] }
]
},
"customfield_10233": {
"type": "doc",
"version": 1,
"content": [
{ "type": "paragraph", "content": [ { "type": "text", "text": "{{issue.customfield_10919}}" } ] }
]
},
"customfield_10231": {
"type": "doc",
"version": 1,
"content": [
{ "type": "paragraph", "content": [ { "type": "text", "text": "{{issue.customfield_10920}}" } ] }
]
},
"customfield_10230": {
"type": "doc",
"version": 1,
"content": [
{ "type": "paragraph", "content": [ { "type": "text", "text": "{{issue.customfield_10921}}" } ] }
]
},
"customfield_10241": {
"type": "doc",
"version": 1,
"content": [
{ "type": "paragraph", "content": [ { "type": "text", "text": "{{issue.customfield_10922}}" } ] }
]
},
"customfield_10244": [{ "value": "{{issue.customfield_10923.value}}" }],
"customfield_11079": "{{issue.key}}",
"customfield_11078": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{ "type": "text", "text": "{{issue.customfield_10520}}" }
]
}
]
}
}
}
{
"fields": {
"summary": "{{issue.summary}}",
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{ "type": "text", "text": {{issue.description.jsonEncode}} }
]
}
]
}
},
"update": {
"labels": [
{{#issue.labels}}
{ "add": "{{.}}" }{{^last}},{{/}}
{{/issue.labels}}
]
}
}
When I use a static value for the description text, the update works.
When I use the smart value ({{issue.description}}
or {{issue.description.jsonEncode}}
), I consistently get a 400 error:{"errorMessages":["There was an error parsing JSON. Check that your request body is valid."]}
Label section works (finally).
I have tried logging the smart value output, using .jsonEncode
, and providing a default value for empty descriptions, but the error persists.
Questions for the Community:
Is there a reliable way to use Jira smart values to update an ADF description field via Automation for Jira in a PUT payload?
Are there known limitations or workarounds for injecting smart values into ADF JSON for rich text fields?
Is there a way to fetch the ADF JSON of the source description and use it directly in the update payload?
Any other best practices for handling ADF and smart values in cross-instance Jira automation?
Additional Context:
Both Jira instances are Cloud.
The automation is triggered by a field change and uses a web request to update the target issue.
The description field is rich text (ADF).
I want to avoid overwriting labels, only append.
Any help or pointers would be greatly appreciated!
Hi @Wendy Quon -- Welcome to the Atlassian Community!
First, the built in automation Edit, Create, and Clone Work Item actions cannot take ADF in the JSON expression at this time. The only way I know how to do this with a rule is with Send Web Request to call the update endpoint directly.
Next, to reduce the chance of errors in the encoding, I recommend first reading the source work item data with the get issue endpoint, and then using smart value, text functions to modify the ADF returned for the Description...and then storing that result in a created variable. That last part helps prevent racetrack timing problems for smart value evaluation (to which the Send Web Request action seems more susceptible). Then use the variable in the JSON for the update endpoint.
Finally, this may take some experimentation, writing values to the log as you proceed, to confirm the JSON contains what you expect for structure and encoding before trying the create / update endpoints.
Kind regards,
Bill
Hi Bill, Let me clarify, this custom data is through the Send Web Request action in the automation rule. The API Endpoint is an OAUTH one due to the API token being scoped and we cannot leverage the basic v3 API URL endpoint.
I've isolated the payload to using the smart value ({{issue.description}}
or {{issue.description.jsonEncode}}
) in addition to the summary and I'm constantly getting errors.
Jira will give me a warning message: "The JSON is valid, but we can't validate your smart value until the rule runs. Check the audit log after the rule runs to ensure it was successful."
So I run the rule and I consistently get a 400 error:
{"errorMessages":["There was an error parsing JSON. Check that your request body is valid."]}
So I have to assume that the JSON body is invalid; HOWEVER, when I use static text, it works. So my mind is flabbergasted at this point. It somehow does not like the issue.description.
Is this a bug? Should I be raising a bug?!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please try first capturing the entire payload with the Create Variable action, perhaps naming the variable varJson. Then write that to the audit log prior to use in the Send Web Request action as {{varJson}}
This will mitigate potential racetrack timing I noted, and allow review of the dynamically built JSON expression in the audit log.
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.