I am trying to follow this example:
https://developer.atlassian.com/server/bitbucket/rest/v806/api-group-pull-requests/#api-api-latest-projects-projectkey-repos-repositoryslug-pull-requests-pullrequestid-comments-post
and I have modified my python code to this:
<span>def</span> <span>create_comment</span>(<span>pr_id, comment</span>):
url = <span>f"http://{baseurl}/rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pr_id}/comments"</span>
headers = {<span>"Accept"</span>: <span>"application/json"</span>, <span>"Content-Type"</span>: <span>"application/json"</span>}
payload = json.dumps({<span>"text"</span>: comment})
response = requests.request(
<span>"POST"</span>,
url,
data=payload,
headers=headers,
verify=<span>False</span>,
auth=HTTPKerberosAuth(mutual_authentication=OPTIONAL),
)
<span>print</span>(response.status_code)
<span>print</span>(
json.dumps(
json.loads(response.text), sort_keys=<span>True</span>, indent=<span>4</span>, separators=(<span>","</span>, <span>": "</span>)
)
)But as a response I always get:
<span>400</span>
{
<span>"errors"</span>: [
{
<span>"context"</span>: null,
<span>"exceptionName"</span>: null,
<span>"message"</span>: <span>"The path query parameter is required when retrieving comments."</span>
}
]
}What am I doing wrong here? I am not trying to retrieve comments. I am trying to add a comment. I can add a ?path=/ to my url, but then I only get an empty list of comments.