There are 6 updates, 1 comment.
 
 
XWiki Docker images / cid:jira-generated-image-avatar-66f8f685-0bdd-4852-af69-9164e00c2f92 XDOCKER-127 Closed

HTTP 405 when trying to create a page with REST API

 
View issue   ·   Add comment
 

6 updates

 
cid:jira-generated-image-avatar-c2f6a280-5b78-4280-9da6-db0a4e437041 Changes by Vincent Massol on 16/Jul/26 11:26
 
Documentation in Release Notes: N/A
Documentation: N/A
Assignee: Vincent Massol
Resolution: Invalid
Labels: bugfixingday
Status: Open Closed
 
 

1 comment

 
cid:jira-generated-image-avatar-c2f6a280-5b78-4280-9da6-db0a4e437041 Vincent Massol on 16/Jul/26 11:26
 

Hi Joey,

The 405 isn't a REST or Tomcat limitation — it's a URL difference between the two distributions.

The XWiki Docker image deploys XWiki as the ROOT webapp in Tomcat (empty context path), whereas the standalone/binary distribution deploys it under the /xwiki context path. That's why the same URL behaves differently.

In your request you're using:

                                                                                                                                                                                                                                                                                            
  http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/NewPage                                                                                                                                                                                                                                                    

Against the ROOT deployment, /xwiki/rest/... doesn't match XWiki's REST servlet mapping (/rest/*), so it falls through to Tomcat's DefaultServlet, which serves static resources and is read-only — hence PUT → HTTP 405 Method Not Allowed (a GET on that same wrong URL would give you a 404, not a 405, which is the
tell-tale sign here).

Just drop the /xwiki context prefix:

                                                                                                                                                                                                                                                                           
  curl -u Admin:admin -X PUT --data-binary "@newpage.xml" \                                                                                                                                                                                                                                                                 
    -H "Content-Type: application/xml" \                                                                                                                                                                                                                                                                                    
    http://localhost:8080/rest/wikis/xwiki/spaces/Main/pages/NewPage                                                                                                                                                                                                                                                        

Note the xwiki after /wikis/ is the wiki name and stays — it's only the leading /xwiki context path that must go.

If you prefer to keep XWiki under /xwiki (so your existing URLs work unchanged), set the CONTEXT_PATH environment variable to xwiki when starting the container — e.g. in docker-compose.yml under the web container's environment: add - CONTEXT_PATH=xwiki. XWiki will then be served at
http://localhost:8080/xwiki/....

Hope this helps!

PS: Next time please don't ask questions in jira, use the XWiki forum for that. Thx