atlassian-python-api
atlassian-python-api copied to clipboard
[Confluence] 404 error when we call the non experimental methods for templates
I am trying to get confluence templates by space_name or by template_id.
My observation:
-
get_template_by_id()is a deprecated method. When I execute this function I get a warning message where it recommends to useget_content_template()instead:DeprecationWarning: Call to deprecated method get_template_by_id. (Use get_content_template()) -- Deprecated since version 3.7.0.
-
Older function
get_template_by_id(template_id=123456789)internally implements "experimental"url = "rest/experimental/template/{template_id}".format(template_id=template_id) -
Newer function
get_content_template(template_id=123456789)internally implements "wiki/rest/api"url = "wiki/rest/api/template/{template_id}".format(template_id=template_id)
-
-
When I use the newer method, I get 404 error (I am masking the actual domain name and template_id for security compliance)
HTTPError: 404 Client Error: for url: https://myconfluence.domain.com/wiki/rest/api/template/123456789
FYI: I am space admin
Can someone replicate and check what can be the issue?
Error trace: (I am masking the actual domain name and template_id for security compliance)
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
D:\VENV\lib\site-packages\atlassian\confluence.py in raise_for_status(self, response)
2677 try:
-> 2678 j = response.json()
2679 error_msg = j["message"]
D:\VENV\lib\site-packages\requests\models.py in json(self, **kwargs)
899 pass
--> 900 return complexjson.loads(self.text, **kwargs)
901
C:\ProgramData\Anaconda3\lib\json\__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
347 parse_constant is None and object_pairs_hook is None and not kw):
--> 348 return _default_decoder.decode(s)
349 if cls is None:
C:\ProgramData\Anaconda3\lib\json\decoder.py in decode(self, s, _w)
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
C:\ProgramData\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 2 column 1 (char 5)
During handling of the above exception, another exception occurred:
HTTPError Traceback (most recent call last)
<ipython-input-13-6261d05783f0> in <module>
----> 1 confluence_api.get_content_template(template_id=123456789) # Error
2 # confluence_api.get_template_by_id(template_id=123456789) # deprecated and recommends to use another method
D:\VENV\lib\site-packages\atlassian\confluence.py in get_content_template(self, template_id)
755
756 try:
--> 757 response = self.get(url)
758 except HTTPError as e:
759 if e.response.status_code == 403:
D:\VENV\lib\site-packages\atlassian\rest_client.py in get(self, path, data, flags, params, headers, not_json_response, trailing, absolute, advanced_mode)
276 headers=headers,
277 trailing=trailing,
--> 278 absolute=absolute,
279 )
280 if self.advanced_mode or advanced_mode:
D:\VENV\lib\site-packages\atlassian\rest_client.py in request(self, method, path, data, json, flags, params, headers, files, trailing, absolute)
240 return response
241
--> 242 self.raise_for_status(response)
243 return response
244
D:\VENV\lib\site-packages\atlassian\confluence.py in raise_for_status(self, response)
2679 error_msg = j["message"]
2680 except Exception:
-> 2681 response.raise_for_status()
2682
2683 raise HTTPError(error_msg, response=response)
D:\VENV\lib\site-packages\requests\models.py in raise_for_status(self)
941
942 if http_error_msg:
--> 943 raise HTTPError(http_error_msg, response=self)
944
945 def close(self):
HTTPError: 404 Client Error: for url: https://myconfluence.domain.com/wiki/rest/api/template/123456789