GetCommentsForPullRequest
Returns comments made on a pull request.
Note
Reaction counts might include numbers from user identities who were deleted after the reaction was made. For a count of reactions from active identities, use GetCommentReactions.
Request Syntax
{
"afterCommitId": "string",
"beforeCommitId": "string",
"maxResults": number,
"nextToken": "string",
"pullRequestId": "string",
"repositoryName": "string"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- afterCommitId
-
The full commit ID of the commit in the source branch that was the tip of the branch at the time the comment was made. Requirement is conditional:
afterCommitIdmust be specified whenrepositoryNameis included.Type: String
Required: No
- beforeCommitId
-
The full commit ID of the commit in the destination branch that was the tip of the branch at the time the pull request was created. Requirement is conditional:
beforeCommitIdmust be specified whenrepositoryNameis included.Type: String
Required: No
- maxResults
-
A non-zero, non-negative integer used to limit the number of returned results. The default is 100 comments. You can return up to 500 comments with a single request.
Type: Integer
Required: No
- nextToken
-
An enumeration token that, when provided in a request, returns the next batch of the results.
Type: String
Required: No
- pullRequestId
-
The system-generated ID of the pull request. To get this ID, use ListPullRequests.
Type: String
Required: Yes
- repositoryName
-
The name of the repository that contains the pull request. Requirement is conditional:
repositoryNamemust be specified whenbeforeCommitIdandafterCommitIdare included.Type: String
Length Constraints: Minimum length of 1. Maximum length of 100.
Pattern:
[\w\.-]+Required: No
Response Syntax
{
"commentsForPullRequestData": [
{
"afterBlobId": "string",
"afterCommitId": "string",
"beforeBlobId": "string",
"beforeCommitId": "string",
"comments": [
{
"authorArn": "string",
"callerReactions": [ "string" ],
"clientRequestToken": "string",
"commentId": "string",
"content": "string",
"creationDate": number,
"deleted": boolean,
"inReplyTo": "string",
"lastModifiedDate": number,
"reactionCounts": {
"string" : number
}
}
],
"location": {
"filePath": "string",
"filePosition": number,
"relativeFileVersion": "string"
},
"pullRequestId": "string",
"repositoryName": "string"
}
],
"nextToken": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- commentsForPullRequestData
-
An array of comment objects on the pull request.
Type: Array of CommentsForPullRequest objects
- nextToken
-
An enumeration token that can be used in a request to return the next batch of the results.
Type: String
Errors
For information about the errors that are common to all actions, see Common Error Types.
- CommitDoesNotExistException
-
The specified commit does not exist or no commit was specified, and the specified repository has no default branch.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- CommitIdRequiredException
-
A commit ID was not specified.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- EncryptionIntegrityChecksFailedException
-
An encryption integrity check failed.
- message
-
Any message associated with the exception.
HTTP Status Code: 500
- EncryptionKeyAccessDeniedException
-
An encryption key could not be accessed.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- EncryptionKeyDisabledException
-
The encryption key is disabled.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- EncryptionKeyNotFoundException
-
No encryption key was found.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- EncryptionKeyUnavailableException
-
The encryption key is not available.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- InvalidCommitIdException
-
The specified commit ID is not valid.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- InvalidContinuationTokenException
-
The specified continuation token is not valid.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- InvalidMaxResultsException
-
The specified number of maximum results is not valid.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- InvalidPullRequestIdException
-
The pull request ID is not valid. Make sure that you have provided the full ID and that the pull request is in the specified repository, and then try again.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- InvalidRepositoryNameException
-
A specified repository name is not valid.
Note
This exception occurs only when a specified repository name is not valid. Other exceptions occur when a required repository parameter is missing, or when a specified repository does not exist.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- PullRequestDoesNotExistException
-
The pull request ID could not be found. Make sure that you have specified the correct repository name and pull request ID, and then try again.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- PullRequestIdRequiredException
-
A pull request ID is required, but none was provided.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- RepositoryDoesNotExistException
-
The specified repository does not exist.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- RepositoryNameRequiredException
-
A repository name is required, but was not specified.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
- RepositoryNotAssociatedWithPullRequestException
-
The repository does not contain any pull requests with that pull request ID. Use GetPullRequest to verify the correct repository name for the pull request ID.
- message
-
Any message associated with the exception.
HTTP Status Code: 400
Examples
Example
This example illustrates one usage of GetCommentsForPullRequest.
Sample Request
>POST / HTTP/1.1
Host: codecommit.us-east-1.amazonaws.com
Accept-Encoding: identity
Content-Length: 176
X-Amz-Target: CodeCommit_20150413.GetCommentsForPullRequest
X-Amz-Date: 20171025T134323Z
User-Agent: aws-cli/1.11.187 Python/2.7.9 Windows/8
Content-Type: application/x-amz-json-1.1
Authorization: AWS4-HMAC-SHA256 Credential=AKIAI44QH8DHBEXAMPLE/20171025/us-east-1/codecommit/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-date;x-amz-target, Signature=8d9b5998EXAMPLE
{
"afterCommitId": "5d036259EXAMPLE",
"beforeCommitId": "317f8570EXAMPLE",
"maxResults": 250,
"nextToken": "exampleToken",
"pullRequestId": 42,
"repositoryName": "MyDemoRepo"
}
Sample Response
HTTP/1.1 200 OK
x-amzn-RequestId: 0728aaa8-EXAMPLE
Content-Type: application/x-amz-json-1.1
Content-Length: 2101
Date: Wed, 25 Oct 2017 20:18:13 GMT
{
"commentsForPullRequestData": [
{
"afterBlobId": "1f330709EXAMPLE",
"afterCommitId": "5d036259EXAMPLE",
"beforeBlobId": "80906a4cEXAMPLE",
"beforeCommitId": "317f8570EXAMPLE",
"comments": [
{
"authorArn": "arn:aws:iam::123456789012:user/Saanvi_Sarkar",
"clientRequestToken": "",
"commentId": "abcd1234EXAMPLEb5678efgh",
"content": "These don't appear to be used anywhere. Can we remove them?",
"creationDate": 1508369622.123,
"deleted": false,
"lastModifiedDate": 1508369622.123,
"callerReactions": [],
"reactionCounts":
{
"THUMBSUP" : 6,
"CONFUSED" : 1
}
},
{
"authorArn": "arn:aws:iam::123456789012:user/Li_Juan",
"clientRequestToken": "",
"commentId": "442b498bEXAMPLE5756813",
"content": "Good catch. I'll remove them.",
"creationDate": 1508369829.104,
"deleted": false,
"commentId": "abcd1234EXAMPLEb5678efgh",
"lastModifiedDate": 150836912.273,
"callerReactions": ["THUMBSUP],
"reactionCounts":
{
"THUMBSUP" : 14
}
}
],
"location": {
"filePath": "ahs_count.py",
"filePosition": 367,
"relativeFileVersion": "AFTER"
},
"repositoryName": "MyDemoRepo",
"pullRequestId": "42"
}
],
"nextToken": "exampleToken"
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: