I am submitting the comments to the issues using REST API, in API 1.0 it was working fine, but from yesterday it stopped working. So now I am integrating API2.0.
As I said when I try to POST a comment to an issue, I am getting
required key not provided
my request follows:
<?php
$content= ["raw" => "test"];
return $this->requestPost(
sprintf('repositories/xxxxx/yyyy/issues/zzz/comments'),
array('content' => $content)
);
?>
I solved my issue. I had to add headers to my curl
-H "Content-Type: application/json"
and in python it's now
resp = requests.post(url, data=json.dumps(payload), auth=(self.vcs_user, self.vcs_token), headers={'Content-Type': 'application/json'})
All better.
Same issue in python, and similar from the curl command line. Smells like a bug.
python3:
url = f'https://api.bitbucket.org/2.0/repositories/{company}/{repo}/pullrequests/{pr_id}/comments'
payload = {
"content": {
"raw": "robo comment",
}
}
resp = requests.post(url, data=payload, auth=(self.vcs_user, self.vcs_token))
print(resp.content)
b'{"type": "error", "error": {"fields": {"content": "expected a dictionary"}, "message": "Bad request"}}'
curl:
$ curl -X POST -H "Authorization: Bearer MDkwg89afxxxxxxxxxxxxxxxxxx" -d '{ "content": { "raw": "some comment" }}' https://api.bitbucket.org/2.0/repositories/<company>/<repo>/pullrequests/<pull_id>/comments
{"type": "error", "error": {"fields": {"content": "required key not provided", "{ \"content\": { \"raw\": \"some comment\" }}": "extra keys not allowed"}, "message": "Bad request"}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you solve it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.