Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add more than one mention when using rest API to create an issue?

paul_dunk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 25, 2025

I am using a V3 rest API to create a Jira ticket. I need to add multiple mentions in the description.  I can add one mention in the description but when I try to add two, Jira complains that "There was an error parsing JSON. Check that your request body is valid."  Can somebody please tell me what is wrong with the body. Thanks!

{ "update": {}, "fields": { "summary": "Test JIRA ticket", "issuetype": { "name": "Task" }, "project": { "key": "BRETRO" }, "reporter": { "id": "BCD-ABC-ABC-ABC" }, "assignee": { "id": "XYZ-ABC-ABC-ABC" }, "description": { "type": "doc", "version": 1, "content": [ { "type": "paragraph", "content": [ { "text": "Description", "type": "text" }, { "type": "hardBreak" }, { "type": "mention", "attrs": { "id": "ABC-ABC-ABC-ABC" } }, { "type": "text", "text": " " }, { "type": "mention", "attrs": { "id": "ABC-ABC-ABC-DEF" } } ] } ] } } }

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
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.
March 26, 2025 edited

Hi @paul_dunk -- Welcome to the Atlassian Community!

To use ADF with the Description, I believe that field must be in "update" with a "set" operation, even though you may put the other fields under "fields".

Please try this one:

{"fields":{"summary":"Test JIRA ticket","issuetype":{"name":"Task"},"project":{"key":"BRETRO"},"reporter":{"id":"BCD-ABC-ABC-ABC"},"assignee":{"id":"XYZ-ABC-ABC-ABC"}},"update":{"description":[{"set":{"type":"doc","version":1,"content":[{"type":"paragraph","content":[{"text":"Description","type":"text"},{"type":"hardBreak"},{"type":"mention","attrs":{"id":"ABC-ABC-ABC-ABC"}},{"type":"text","text":" "},{"type":"mention","attrs":{"id":"ABC-ABC-ABC-DEF"}}]}]}}]}}

 

I recommend uncompressing / formatting that expression and reviewing it before use.

Kind regards,
Bill

 

PS: Would one of the community leaders / managers please move this question from App Central to the Jira product, questions area?  Thank you!

paul_dunk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 26, 2025

Thanks very much Bill.  I entered the expression in JSON formatter and it looked good to me.  Unfortunately, Jira still had an error parsing the body.

Also, thanks for asking to have this question moved to the Jira product area.

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.
March 26, 2025

I tested that JSON, substituting in my own Project Key and user accountId values for the mentions, reporter, and assignee and it worked (from an automation rule test action).

I recommend pausing and trying a basic Get Issue with whatever tooling you are using to confirm that is working first.  And if that works...

  • try adding a Create Issue with no reporter, assignee or mentions
  • if that works, add the reporter and assignee to the JSON
  • if that works, add one mention to the Description's ADF in the JSON
  • if that works, add the second mention
paul_dunk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 26, 2025

Thanks Bill.  That's interesting, encouraging and frustrating.  I will take a closer look at what I am actually sending and compare it to your expression.

Both the GET and incremental create ideas are good advice.

My GET works.  If I have manually entered two mentions in the issue, then they display with the notation that I am using for my POST. 

The create works up until I add the second mention.

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.
March 26, 2025

Is that error from your request / tool before sending, or a response from the endpoint request?

 

Also, I note you try to add a single space between the mentions.  Try putting some other text in there for more visibility between the entries.  Perhaps there is something in your JSON parser / validator which is collapsing the space and does not like the empty string in the message.

TAGS
AUG Leaders

Atlassian Community Events