Hi everyone
Im trying to update an already created page via Rest API with the following code
curl -u u:p -X PUT -H "Content-Type: application/json" -d {"id":"21169510","type":"page","title":"Test Doors","space":{"key":"TOOL"},"body":{"storage":{"value":"<p>UPDATE This is a new page</p>","representation":"storage"}},"version":{"number":2}} http://confluence.xxx:8090/confluence/rest/api/content/21169510
And Im getting this:
<!doctype html><html lang="en"><head><title>HTTP Status 405 – Method Not Allowed</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 405 – Method Not Allowed</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The method received in the request-line is known by the origin server but not supported by the target resource.</p><hr class="line" /><h3>Apache Tomcat/9.0.22</h3></body></html>
Does anybody know what am I doing wrong?
Hi @[deleted] welcome to the community!
This is how I was able to update an existing page -
curl -u username:password --request PUT 'https://kishansharma.confluence.com/confluence/rest/api/content/007' \
--header 'Content-Type: application/json' \
--data-raw '{
"type":"page",
"title":"My Test Page",
"version":{"number":2},
"space":{"key":"MySpace"},
"body":{
"storage":{
"value":"<p>This is version 2 - have made some changes</p>",
"representation":"storage"
}
}
}'
Hi @[deleted] ,
welcome to the Atlassian Community!
I believe in general this should work and your request is correct. You don't need to send id and space parameter in the request, but I don't think that's the problem here.
Even though you are clearly sending PUT, it seems to me something is causing the method to be changed or removed somehow (?). Because PUT should be allowed method.
I've found similar question here, but I don't know if it helps you.
If you use Postman to send the request, are you able to suceed? Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using Postman i get this:
<!doctype html>
<html lang="en">
<head>
<title>HTTP Status 405 – Method Not Allowed</title>
<style type="text/css">
h1 {
font-family: Tahoma, Arial, sans-serif;
color: white;
background-color: #525D76;
font-size: 22px;
}
h2 {
font-family: Tahoma, Arial, sans-serif;
color: white;
background-color: #525D76;
font-size: 16px;
}
h3 {
font-family: Tahoma, Arial, sans-serif;
color: white;
background-color: #525D76;
font-size: 14px;
}
body {
font-family: Tahoma, Arial, sans-serif;
color: black;
background-color: white;
}
b {
font-family: Tahoma, Arial, sans-serif;
color: white;
background-color: #525D76;
}
p {
font-family: Tahoma, Arial, sans-serif;
background: white;
color: black;
font-size: 12px;
}
a {
color: black;
}
a.name {
color: black;
}
.line {
height: 1px;
background-color: #525D76;
border: none;
}
</style>
</head>
<body>
<h1>HTTP Status 405 – Method Not Allowed</h1>
<hr class="line" />
<p><b>Type</b> Status Report</p>
<p><b>Description</b> The method received in the request-line is known by the origin server but not supported by the
target resource.</p>
<hr class="line" />
<h3>Apache Tomcat/9.0.22</h3>
</body>
</html>
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.