API REST : filters not visible
Moderators: Developer, Contributor
-
daan_mantis
- Posts: 6
- Joined: 03 Oct 2024, 16:51
API REST : filters not visible
Dear mantis community,
Mantis version : 2.22.0
I am trying to access my mantis database using python request and API rest
I have created a API token, and I can access issues with url like ".../api/rest/issues/145"
But for some reasons, I get an empty list of filters when requesting url ".../spi/rest/filters"
When beeing logged in my browser using my login authentification, the same url returns the expected list of filters
API token was created using my own login, so imo, my pthon script should be able to see the same filters
Any idea what I am missing?
Thanks for your support,
PS : I have tested using SOAP API, and it seems there is the same issue
Mantis version : 2.22.0
I am trying to access my mantis database using python request and API rest
I have created a API token, and I can access issues with url like ".../api/rest/issues/145"
But for some reasons, I get an empty list of filters when requesting url ".../spi/rest/filters"
When beeing logged in my browser using my login authentification, the same url returns the expected list of filters
API token was created using my own login, so imo, my pthon script should be able to see the same filters
Any idea what I am missing?
Thanks for your support,
PS : I have tested using SOAP API, and it seems there is the same issue
Re: API REST : filters not visible
Does your code work on the following URL?
https://mantisbt.org/bugs/api/rest/filters
https://mantisbt.org/bugs/api/rest/filters
-
daan_mantis
- Posts: 6
- Joined: 03 Oct 2024, 16:51
Re: API REST : filters not visible
Hi, thanks for your answer
When I run my code on your URL, I get an exception because of invalid SSL certification
My url is an "http" one, so I don't this kind of issue
my code is very simple and come directly from the documentation:
When I run my code on your URL, I get an exception because of invalid SSL certification
Exception has occurred: SSLError
HTTPSConnectionPool(host='mantisbt.org', port=443): Max retries exceeded with url: /bugs/api/rest/filters (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1124)')))
My url is an "http" one, so I don't this kind of issue
my code is very simple and come directly from the documentation:
Code: Select all
import requests
import jsons
url = "http://xxxx/api/rest/filters"
url_test = "https://mantisbt.org/bugs/api/rest/filters"
token = "39qeFQccqDsdfsfdsqk4YPZDMuiG9"
payload={}
headers = {
'Authorization': token
}
response = requests.request("GET", url , headers=headers, data=payload)
print(response.text)Re: API REST : filters not visible
No problem when running the following code on Windows using Python 3.12.7
Code: Select all
import requests
import jsons
url = "https://mantisbt.org/bugs/api/rest/filters"
token = "MyTokenRepaceByYourToken"
payload={}
headers = {
'Authorization': token
}
response = requests.request("GET", url , headers=headers, data=payload)
print(response.text)-
daan_mantis
- Posts: 6
- Joined: 03 Oct 2024, 16:51
Re: API REST : filters not visible
for me, https://mantisbt.org/bugs/api/rest/filters returns also an empty list "{"filters":[]}" (is it normal?)
What could possibly explain that (on my url), the expected list is returned by chrome, and an empty list when using token authentification in my script?
Can it be that the mantis server is configured to react differently if the request comes from token authentification?
At the end, what I want to do is the ability to retrieve a list of issues matching a specific filter (we have several thousands in the database). I understand the only way to do it with REST is to define a static filter using the mantis front end webinterface, and then use it in a script, am I right?
I don't see a way to create the filter directly in the script...
What could possibly explain that (on my url), the expected list is returned by chrome, and an empty list when using token authentification in my script?
Can it be that the mantis server is configured to react differently if the request comes from token authentification?
At the end, what I want to do is the ability to retrieve a list of issues matching a specific filter (we have several thousands in the database). I understand the only way to do it with REST is to define a static filter using the mantis front end webinterface, and then use it in a script, am I right?
I don't see a way to create the filter directly in the script...
Re: API REST : filters not visible
Right, it's available for SOAP but not REST, see https://mantisbt.org/bugs/view.php?id=26471daan_mantis wrote: 04 Oct 2024, 07:27 At the end, what I want to do is the ability to retrieve a list of issues matching a specific filter (we have several thousands in the database). I understand the only way to do it with REST is to define a static filter using the mantis front end webinterface, and then use it in a script, am I right?
-
daan_mantis
- Posts: 6
- Joined: 03 Oct 2024, 16:51
Re: API REST : filters not visible
pretty sure yes...
I log into the mantis project, on the top right, I select "My Account", and I create an API token in there, and use it in my script. I tried already revoking and trying with a new one.
My user can access 10 public filters, and 5 private ones, all 15 visible in Chrome, none by python
I log into the mantis project, on the top right, I select "My Account", and I create an API token in there, and use it in my script. I tried already revoking and trying with a new one.
My user can access 10 public filters, and 5 private ones, all 15 visible in Chrome, none by python
Re: API REST : filters not visible
So you are testing on your system but not https://mantisbt.org as you are not allowed to store filters on mantisbt.orgdaan_mantis wrote: 04 Oct 2024, 08:23 My user can access 10 public filters, and 5 private ones, all 15 visible in Chrome, none by python
Right?
Please try also on mantisbt.org
I would like to find out in a first step, if the issue is on the client or the server side.
The biggest difference is that you are running a pretty outdated MantisBT 2.22.0 version, so I recommend to upgrade to latest stable one.
As 2.27.0 is pretty new, I would take 2.26.4 at the moment.
In best case, your issue is fixed after that.
-
daan_mantis
- Posts: 6
- Joined: 03 Oct 2024, 16:51
Re: API REST : filters not visible
Hi,
OK I tried with mantisbt.org (had to create an account first), created an API token, and it works ... I managed to get the list of filters via my python script.
So it looks like the pb is on server side... Unfortuntely I am not able to upgrade easily the version of mantisbt (managed by my company IT like worldwide :/)
Is it a known issue of 2.22 version?
OK I tried with mantisbt.org (had to create an account first), created an API token, and it works ... I managed to get the list of filters via my python script.
So it looks like the pb is on server side... Unfortuntely I am not able to upgrade easily the version of mantisbt (managed by my company IT like worldwide :/)
Is it a known issue of 2.22 version?
Re: API REST : filters not visible
I am not aware that there was a specific fix for this API endpoint, you might want to check the changelog https://mantisbt.org/bugs/changelog_page.php
The bug might have been fixed as side effect of another fix, mabye also in one of our updated 3rd party components.
Certainly interesting for you in next step, this fix in 2.23.0 https://mantisbt.org/bugs/view.php?id=26195
The bug might have been fixed as side effect of another fix, mabye also in one of our updated 3rd party components.
Certainly interesting for you in next step, this fix in 2.23.0 https://mantisbt.org/bugs/view.php?id=26195
-
daan_mantis
- Posts: 6
- Joined: 03 Oct 2024, 16:51
Re: API REST : filters not visible
OK I think found the issue (it is working now, but not 100% sure why), but I am taking some time to post the solution here for the poor soul who may get the same issue
I think the issue is that my default project in account preference was set to "all_projects" which associated "viewer" role
Apparantly as viewer role, you can't see any filters at all. This is apparantly why my python script couldn't see anything because it acts as a viewer only by default
As soon as a changed the default project to the one I have manager role, the API rest can see the filters
It was working using the browser because it uses the active project selected in the main page (top right list)
I think the issue is that my default project in account preference was set to "all_projects" which associated "viewer" role
Apparantly as viewer role, you can't see any filters at all. This is apparantly why my python script couldn't see anything because it acts as a viewer only by default
As soon as a changed the default project to the one I have manager role, the API rest can see the filters
It was working using the browser because it uses the active project selected in the main page (top right list)