405 when updating a template via postman

Hello, I am trying to update a template via the REST-API using Postman.

I am using basic auth and GET requests work fine.

Any Idea what could be going wrong?

Hello @MichaelIlewicz

What is the value of the {{baseUrl}} variable?

Are your PUT requests working with all the other update type endpoints?

baseUrl is mydomain.atlassian.net/wiki/rest

I tried the update space endpoint, which returns OK but the value doesn’t change (I tried to change the descriptionof a space)

That complete URL of https://{yourdomain}.atlassian.net/wiki/rest/api/template is a valid endpoint path and the body of the request looks correct, so you have some other problem somewhere else in your request.

Perhaps a bad header definition? Perhaps a misconfiguration of the Basic auth structure. Sorry, but they are too many possibilities for me to randomly guess what it might be. I can only say that all the v1 API Content Template management endpoints work just fine for me (and probably everyone else) using either Basic Auth or OAuth.

I suggest you do some classic, step-by-step experiments to isolate the fault

  1. Use Postman with the Create Content Template endpoint to create (POST) a new Page Template.
  2. Use the Confluence GUI to confirm it was created and the name and content is as expected
  3. Use Postman to GET the details of that new Page Template and validate the API response replicates what you saw in the GUI
  4. Use Postman to try and PUT updates into that new Page Template, using the GUI again to validate any changes.

If in doubt, rebuild your Postman requests or re-import the Postman Collection from the REST API documentation. Trying using cURL as an alternative tool to test the requests.

Be systematic.

1 Like

@MichaelIlewicz,

The status code is quite specific: 405 Method Not Allowed. What troubles me is the URL pattern doesn’t look right for a PUT. For example, if you want to update a space the docs show PUT /wiki/rest/api/space/{spaceKey}. The resource’s identification is typically part of the path for a PUT.

I’m guessing the OpenAPI spec might be wrong. Can you try PUT /wiki/rest/api/template/{templateId}? If that works, let us know and I’ll get a bug filed.

Howdy @ibuchanan

I can advise that the PUT request path that @MichaelIlewicz is using for updating a Content Template is correct. Yes, I know it’s very strange that the endpoint requires that templateId is not declared as a URL parameter but is declared in the request body, but that is what works:

If I attempt to use PUT /wiki/rest/api/template/{templateId}, as you would assume, then it fails with a 405 Method Not Allowed error.

Check the Update Content Template documentation.

1 Like

Apparently, postman automatically redirects 3XX calls without maintaining the type, changing it to a GET in the process. After disabling automatic redirects, the original PUT request returns 301 permantently moved. The solution was, to specify https:// before mydomain :slight_smile:

1 Like