Page 1 of 1

How to get all mantis users via api rest?

Posted: Mar 06, 2018 9:26 am
by Cosmin
Hello,
Is any way to get all mantis users through api rest?
Thanks

Re: How to get all mantis users via api rest?

Posted: Mar 09, 2018 5:39 am
by atrol
There is no such function in REST API at the moment.

Re: How to get all mantis users via api rest?

Posted: Mar 09, 2018 12:45 pm
by Starbuck
Plugin time?

Re: How to get all mantis users via api rest?

Posted: Mar 09, 2018 4:31 pm
by Starbuck
I don't know if there is a way to create a plugin for the REST API yet.
For now, this is a drop-in replacement to the core file that handles the REST requests for users.

That entire file will replace /api/rest/restcore/users_rest.php.

Changes to support this feature:
- There is now a GET end-point at the root of the /users path : /api/rest/users/
- Added function rest_users_get, a slightly modified version of reset_user_get_me that just loops on all users.

If this does the job I'll submit the enhancement to core for consideration.
Extensions from this can easily get any specific user, get users filtered by criteria, and sort the results.

Re: How to get all mantis users via api rest?

Posted: Mar 09, 2018 4:42 pm
by Starbuck
I just found a good example for adding a new REST end point.
If the enhancement is rejected as a core update, I'll publish it as a plugin.

Re: How to get all mantis users via api rest?

Posted: Mar 09, 2018 5:20 pm
by atrol
@Starbuck I am pretty sure this will not work on installations with lots of users due to various reasons (exceeding post max size, max cpu and memory).
There is the need to implement a paging similar to the paging that is implemented for issues.

Re: How to get all mantis users via api rest?

Posted: Mar 09, 2018 5:51 pm
by Starbuck
Now you're sounding like a user. We've provided a fast and free solution, changing a No answer to Yes, and you're saying it's not good enough. :mrgreen:

We can provide solutions fast, good, or cheap - pick two. For a better balance, options available to businesses that have high demands as you describe, including:
  • Get one of those many Mantis users to enhance the provided code.
  • Motivate someone else to enhance it.
  • Put the software into an environment that will handle the user load.
  • Increase the response timeout for a client process making the REST request.

Re: How to get all mantis users via api rest?

Posted: Mar 10, 2018 8:26 am
by atrol
Starbuck wrote:
Mar 09, 2018 5:51 pm
Now you're sounding like a user.
User? Users are typically not aware of such technical constraints.
I am writing as a developer, kwowing how it works in background, being aware of real life use cases.
Starbuck wrote:
Mar 09, 2018 4:31 pm
If this does the job I'll submit the enhancement to core for consideration.
If you send a PR, the mentioned paging should be implemented, to increase the chance that the change will become part of the core.

BTW, I tried the patch on a system similar to the instance on mantisbt.org and got exactly what I expected to get:
A stressed server, especially database and finally: PHP Fatal error: Allowed memory size exhausted.

For users reading this:
The patch works in general, but shouldn't be used on systems with large number of users and/or projects.

Re: How to get all mantis users via api rest?

Posted: Jan 17, 2019 9:45 am
by pgiraud
atrol wrote:I tried the patch
@atrol or @Starbuck can you please point me to the mentioned patch?

I'm also interested in any resource that could help me writing a plugin to enhance or extend the current Rest API. I'd like to be able to search for users, or update a user (changing his email address for example).

Thanks for you help.

Re: How to get all mantis users via api rest?

Posted: Jan 18, 2019 3:11 am
by pgiraud
Oh crap, sorry for the noise. I didn't figure out that there was a patch behind the "drop-in replacement" link.

Re: How to get all mantis users via api rest?

Posted: Jan 21, 2019 4:24 pm
by Starbuck
No prob. If you'd ike to discuss plugin creation, check out the forum section dedicated to that topic. (See my sig)
Just a note - I'm no expert in the area and don't have a lot of time right now to provide many details. My goal is to provide a forum for such discussions, to attract "like minds" to share information on a topic, even if I myself can't be the answer guy.
But give it a shot!