Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

Could you solve it?

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

 

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,892 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you