As described in the summary - I am using ScriptRunner. Here is the code I am trying to run:
def commentBody = [
"type": "doc",
"version": 1,
"content": [
"type": "paragraph",
"content": [
"type": "text",
"text": "The group could not be created. Response:"
]
]
]
post("/rest/api/3/issue/GS-1/comment")
.basicAuth(SERVICE_USER, SERVICE_API_TOKEN)
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.body(commentBody)
.asJson()
Here is the response:
POST request to /rest/api/3/issue/GS-1/comment returned an error code: status: 400 - Bad Request body: {"errorMessages":[],"errors":{"comment":"Comment body can not be empty!"}}
I followed ADF documentation here: https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/
Any idea where the problem could be?
Thanks!
Hi @Adam Rypel _MoroSystems_ , the correct format of the request is:
def commentBody = [ body: [
type: "doc",
version: 1,
content: [
[
type: "paragraph",
content: [
[
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
type: "text"
]
]
]
]
]]
Thanks! This one works as intended
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The errors is saying it's missing the body part to the actual api post. Could you try updating your code and see if this helps.
def commentBody = {"body":
[
"type": "doc",
"version": 1,
"content": [
"type": "paragraph",
"content": [
"type": "text",
"text": "The group could not be created. Response:"
]
]
]
}
Thanks,
Tim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks! Body was indeed the problem, just had to adjust syntax as Martin said:
def commentBody = [ body: [
type: "doc",
version: 1,
content: [
[
type: "paragraph",
content: [
[
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
type: "text"
]
]
]
]
]]
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.