How to get all mantis users via api rest?

Get help from other users here.

Moderators: Contributor, Developer

Post Reply
Cosmin
Posts: 5
Joined: Jan 15, 2018 4:22 am

How to get all mantis users via api rest?

Post by Cosmin » Mar 06, 2018 9:26 am

Hello,
Is any way to get all mantis users through api rest?
Thanks

atrol
Site Admin
Posts: 7579
Joined: Mar 26, 2008 4:37 pm
Location: Germany

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

Post by atrol » Mar 09, 2018 5:39 am

There is no such function in REST API at the moment.
Please use Search before posting and read the Manual

Starbuck
Posts: 176
Joined: Feb 13, 2006 9:53 pm
Location: USA
Contact:

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

Post by Starbuck » Mar 09, 2018 12:45 pm

Plugin time?
If you want Mantis to work differently, use or create a plugin. Visit the Plugins forums.
Ask developers to create a plugin that you need - and motivate them to help you!

Starbuck
Posts: 176
Joined: Feb 13, 2006 9:53 pm
Location: USA
Contact:

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

Post by Starbuck » Mar 09, 2018 4:31 pm

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.
If you want Mantis to work differently, use or create a plugin. Visit the Plugins forums.
Ask developers to create a plugin that you need - and motivate them to help you!

Starbuck
Posts: 176
Joined: Feb 13, 2006 9:53 pm
Location: USA
Contact:

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

Post by Starbuck » Mar 09, 2018 4:42 pm

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.
If you want Mantis to work differently, use or create a plugin. Visit the Plugins forums.
Ask developers to create a plugin that you need - and motivate them to help you!

atrol
Site Admin
Posts: 7579
Joined: Mar 26, 2008 4:37 pm
Location: Germany

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

Post by atrol » Mar 09, 2018 5:20 pm

@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.
Please use Search before posting and read the Manual

Starbuck
Posts: 176
Joined: Feb 13, 2006 9:53 pm
Location: USA
Contact:

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

Post by Starbuck » Mar 09, 2018 5:51 pm

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.
If you want Mantis to work differently, use or create a plugin. Visit the Plugins forums.
Ask developers to create a plugin that you need - and motivate them to help you!

atrol
Site Admin
Posts: 7579
Joined: Mar 26, 2008 4:37 pm
Location: Germany

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

Post by atrol » Mar 10, 2018 8:26 am

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.
Please use Search before posting and read the Manual

pgiraud
Posts: 3
Joined: Jan 17, 2019 3:48 am

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

Post by pgiraud » Jan 17, 2019 9:45 am

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.

pgiraud
Posts: 3
Joined: Jan 17, 2019 3:48 am

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

Post by pgiraud » Jan 18, 2019 3:11 am

Oh crap, sorry for the noise. I didn't figure out that there was a patch behind the "drop-in replacement" link.

Starbuck
Posts: 176
Joined: Feb 13, 2006 9:53 pm
Location: USA
Contact:

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

Post by Starbuck » Jan 21, 2019 4:24 pm

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!
If you want Mantis to work differently, use or create a plugin. Visit the Plugins forums.
Ask developers to create a plugin that you need - and motivate them to help you!

Post Reply