The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

throws required key not provided when submit comments using REST API 2.0

jothi kannan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 27, 2019

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)
);

?>

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Earl Berg
April 3, 2020

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.

1 vote
Earl Berg
April 3, 2020

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"}}

 

0 votes
BadChoice
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 30, 2019

Could you solve it?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

TAGS
AUG Leaders

Atlassian Community Events