python-redmine icon indicating copy to clipboard operation
python-redmine copied to clipboard

Get Request - ResourceNotFoundError: Requested resource doesn't exist

Open kharisd opened this issue 9 months ago • 1 comments

Hi,

Wanted to get an issue from the redmine api I work with, however when I run this code I get an unexpected error.

The version I installed on python 3.9.18:

pip install python-redmine==2.5.0
Collecting python-redmine==2.5.0
  Downloading python_redmine-2.5.0-py3-none-any.whl (39 kB)
Collecting requests>=2.31.0
  Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting urllib3<3,>=1.21.1
  Downloading urllib3-2.2.1-py3-none-any.whl (121 kB)
     |████████████████████████████████| 121 kB 12.0 MB/s 
Collecting idna<4,>=2.5
  Downloading idna-3.7-py3-none-any.whl (66 kB)
     |████████████████████████████████| 66 kB 13.0 MB/s 
Collecting charset-normalizer<4,>=2
  Using cached charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2024.2.2-py3-none-any.whl (163 kB)
     |████████████████████████████████| 163 kB 42.1 MB/s 
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests, python-redmine
Successfully installed certifi-2024.2.2 charset-normalizer-3.3.2 idna-3.7 python-redmine-2.5.0 requests-2.31.0 urllib3-2.2.1

Code to reproduce error:

from redminelib import Redmine

url = "redmine-api-url-here"
rm_token = "token"
redmine = Redmine(url, key=rm_token)

issue = redmine.issue.get(2728268)
print(issue)

Expected Behavior Name of the redmine issue printed and issue returned. (Works with python-redmine==2.4.0 & issue exists in my redmine)

Observed Behavior

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib64/python3.9/site-packages/redminelib/managers/base.py", line 103, in get
    raise e
  File ".venv/lib64/python3.9/site-packages/redminelib/managers/base.py", line 99, in get
    response = self.redmine.engine.request('get', self.url, params=self.params)
  File ".venv/lib64/python3.9/site-packages/redminelib/engines/base.py", line 84, in request
    return self.process_response(self.session.request(method, url, **kwargs))
  File ".venv/lib64/python3.9/site-packages/redminelib/engines/base.py", line 179, in process_response
    raise exceptions.ResourceNotFoundError
redminelib.exceptions.ResourceNotFoundError: Requested resource doesn't exist

Possible that I may be running something wrong. Any help is appreciated.

Thank you!

kharisd avatar Apr 29 '24 19:04 kharisd

Hi @kharisd

If it works with python-redmine 2.4.0 and doesn't work with 2.5.0 then most probably the issue is connected with a backwards incompatible change regarding API key (from the changelog):

API key is now being sent in the X-Redmine-API-Key header instead of the key GET parameter which makes things more secure in case of a failed connection, but it might created issues for servers that don’t do custom request header forwarding by default, so be sure to check your web server before upgrading

So check if your web server does custom header forwarding and if it doesn't turn it on for all headers or enable it just for the header X-Redmine-API-Key.

maxtepkeev avatar Apr 30 '24 14:04 maxtepkeev

Closing this due to inactivity.

maxtepkeev avatar Jul 06 '24 09:07 maxtepkeev