lesstif / php-jira-rest-client

PHP classes interact Jira with the REST API.
Other
510 stars 263 forks source link

addComment getting `Comment body is not valid!` #412

Closed wimg-bstuckey closed 2 years ago

wimg-bstuckey commented 2 years ago

here is my code

        // ADD COMMENT
$commentBody = <<<COMMENT
TEST
COMMENT;

        $comment->setBody( $commentBody )
                ->setVisibility( "role", "Users");

        $issueService->addComment( $issueKey, $comment );

not quit sure what is wrong with my comment body... i am using v3 for the rest of my api functions before this... is this an issue with v2 vs v3?

here are some logs

[2022-01-25T16:13:11.334221+00:00] JiraClient.INFO: addComment=  [] []
[2022-01-25T16:13:11.334268+00:00] JiraClient.INFO: Curl : https://***.atlassian.net/rest/api/3/issue/KEY-123/comment JsonData={"body":"TEST","visibility":{"type":"role","value":"Users"}} [] []
[2022-01-25T16:13:11.334311+00:00] JiraClient.DEBUG: Curl exec=https://***.atlassian.net/rest/api/3/issue/KEY-123/comment [] []
wimg-bstuckey commented 2 years ago

I think im reading jira api docs right https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post

var bodyData = `{
  "visibility": {
    "type": "role",
    "value": "Administrators"
  },
  "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"
          }
        ]
      }
    ]
  }
}`;

const response = await api.asApp().requestJira(route`/rest/api/3/issue/{issueIdOrKey}/comment`, {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: bodyData
});

and this is what the current SDK is sending JsonData={"body":"TEST", where body is just a string... i guess what i am saying is it looks like it is a V2 vs V3 issue... but seems like it maybe an easy thing to hack real quick locally until a CommentV3 is made like DescriptionV3

wimg-bstuckey commented 2 years ago

ooo was just searching the code and see lesstif/php-jira-rest-client/src/Issue/CommentV3.php

lesstif commented 2 years ago

@wimg-bstuckey sorry I'm late, could you resolve your issue?

wimg-bstuckey commented 2 years ago

@wimg-bstuckey sorry I'm late, could you resolve your issue?

Sorry, i forgot to come back and mark this as resolved. Once i found CommentV3 it worked just fine :)