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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,457,230
Community Members
 
Community Events
176
Community Groups

Confluence API: Trying to create a new page throws a 405 error

I'm trying to create a new page that is a child of an existing page using the Confluence API. I'm writing this in Python but not using the Confluence Python API module. I keep getting a 405 error returned and am not sure why. Here's my code: 

In towu.py: 

def addPage(pageId, strCotent):

strURL = "https://kargo1.atlassian.net/wiki/rest/api/content/" + pageId + "?expand=body.storage,version"

#get current version of page
dictResults = AppManager.makeGetCall("https://kargo1.atlassian.net/wiki/rest/api/content/" + pageId + "?expand=version")
version = int(dictResults["data"]["version"]["number"]) + 1

#page data
dictPayload = {
"type":"page",
"title":"Tech Ops Weekly Update Test",
"ancestors":[{"id":draftsId}],
"space":{"key":"KTC"},
"body":{
"storage":{
"value":"<ac:layout><ac:layout-section ac:type=\"fixed-width\" ac:breakout-mode=\"default\"><ac:layout-cell><h2>Tech Ops Incident Report Wrap Up for Week Ending: 2022-07-25</h2>",
"representation":"storage"
}
}
}

dictResults = AppManager.makePostCall(strURL, dictPayload)
print(dictResults)

 

and in my AppManager.py file: 

def makePostCall(strURL, payload):

payloadJSON = json.dumps(payload)

response = requests.request("POST", strURL, data=payloadJSON, headers=strJiraHeader)

if response.status_code == 200:
return {"success":True, "data":response.json()}
elif response.status_code > 200:
return {"success":False, "msg":"There was an error with updating your file: " + str(response.status_code) + "\n" + response.reason}
and the return from makePostCall is: 

{'success': False, 'msg': 'There was an error with updating your file: 405\nMethod Not Allowed'} 

I have permission (I'm the site admin). I know the headers work as I can make a variety of GET calls with it. I also tried a PUT call to an existing page and got a 400 error back. 

Not sure what I am doing wrong here, any help would be appreciated.  

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events