Forums

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

add Comment API error Invalid request payload. Refer to the REST API documentation and try again.

Jenni
Contributor
October 6, 2023
const bodyData = {
body: {
content: [
{
content: [
{
text: "contentlfjdlfkjsf",
type: "text",
},
],
type: "paragraph",
},
],
type: "doc",
version: 1,
},
visibility: {
identifier: "Administrators",
type: "role",
value: "Administrators",
},
};

above is my bodyData.

I sent through below 

const url = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${issueId}/comment`;
fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
Accept: "application/json",
"Content-Type": "application/json",
},
body: bodyData,
})
.then((response) => {
return response.json();
})
.then((data) => {
resolve(data);
})
.catch((err) => {
logger.error(err);
reject(err);
});


I did this but I get an error message:
"error Invalid request payload. Refer to the REST API documentation and try again."


what am I doing wrong...


so I did JSON.Stringify(bodyData)

then I git a new error message: 'The body parameters 'value' and 'identifier' are mutually exclusive.'


.. please help

1 answer

1 accepted

0 votes
Answer accepted
Jenni
Contributor
October 6, 2023

I deleted "visibility" part and it returns a success response but I don't see the actual comment added to my issue... 

Jenni
Contributor
October 6, 2023

So I figured it out that I needed to add visbility and simply add members to the project Role to view comments.
hope my answer helps others who struggle with the same issue 

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 6, 2023

Hi @Jenni 

As you have solved this, please mark your own solution as "answered" to help others in the community.  Thanks!

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events