Closed richardgavel closed 5 years ago
Sorry for the delay in replying. On which call in the library are you seeing this?
Sorry for the feedback delay. This is the call. https://github.com/lvermeulen/Bitbucket.Net/blob/a3525006ce394c9af223f991ed638cbba0823e3a/src/Bitbucket.Net/Core/Projects/BitbucketClient.cs#L1236. Even though the invocation supports providing only the comment itself, with the other parameters optional, those nulls will still be made part of the JSON that gets posted instead of non-existent properties.
This is the exact code I'm using in a replacement:
public async Task CreatePullRequestCommentAsync(string projectKey, string repositorySlug, long pullRequestId, string text)
{
try
{
var requestUri = $"rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments";
var body = new
{
text
};
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.Default, "application/json");
var response = await _httpClient.PostAsync(requestUri, content);
response.EnsureSuccessStatusCode();
}
catch (HttpRequestException ex)
{
_logger.LogError(ex, "Error creating pull request comment ({Message})", ex.Message);
throw;
}
}
I'm on it.
I will push out a fix hopefully this weekend.
Fixed in release 2.1.6
I get a 404 when trying to add a pull request comment that is not linked to a specific line of code. This despite being able to do so if I POST to the same URI, with a body of just { text = "comment" }. I imagine it is because the rest of the JSON body is actually being populated with data that does not apply in a global PR comment.