I am trying to add a comment to a confluence Page through REST API. But I gives me a "The specified HTTP method is not allowed for the requested resource." error.
This is what I am trying to do.
from json import dumps, load
from base64 import b64encode
from urllib2 import Request, urlopen
username = "admin"
password = "q*****3"
newTestValues = dumps({
"type":"comment",
"body": "Only single comment at a time"
})
headers = {"Authorization": " Basic " + b64encode(username + ":" + password), "Content-Type": "application/json"}
try:
pageData = json.dumps({
"type":"comment",
"title":"Meeting notes : Staffing discussion - expanded support and development",
"body":{
"storage":{
"value":"<p>wwwwwwoooooooowwwwwww</p>",
"representation":"storage"
}
}
}
)
request = Request('https://j***************a.atlassian.net/wiki/rest/api/latest/content/1146976/child',data=pageData,headers=headers)
js_res = urlopen(request)
objResponse = load(js_res)
print objResponse
except urllib2.HTTPError, error:
print error.read()
Community moderators have prevented the ability to post new answers.
Hello Jag,
Thank you for your question.
You could run the following:
import requests, json # PAGE_ID, get from https://DOMAIN.atlassian.net/wiki/rest/api/content pageData = { 'body':{ 'storage':{ 'value':"<p>A new comment test</p>", 'representation':'storage' } }, 'container':{ 'type':'page', 'id':'PAGE_ID' }, 'type':'comment', } r = requests.post('https://DOMAIN.atlassian.net/wiki/rest/api/content', data=json.dumps(pageData), auth=('USERNAME','PASSWORD'), headers=({'Content-Type':'application/json'})) printResponse(r)
If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.
Thank you for your understanding.
—
Kind regards,
Rafael P. Sperafico
Atlassian Support
im trying to append a comment to a comment using (PHP)
$j['type'] = 'comment';
$j['space']['key'] = <SPACEKEY>;
$j['container']['id'] = <PARENTCONTENID>;
$j['container']['type'] = 'comment';
$j['body']['storage']['value'] = '<p>content ...</p>';
$j['body']['storage']['representation'] = 'storage';
curl post is ok - comment object is created - but it is not showen in the frontend!?
any idea
b
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.