Upgrading from UserService to RESTApi

All,

Thanks in advance for any help with this. I had Openfire 3.9.3, but needed to upgrade to 3.10.2, and will probably continue to keep the Openfire installation up to date. I had a series of scripts to create http requests using the UserService plugin, but that no longer works with the new version of Openfire. So, I installed the RESTapi plugin, enabled the service and added a secret key. According to the documentation, I should be able to do much the same with RestApi that I did with the UserService, but I get no return data or status from sending the HTTP request. I’m using a simple lynx like line browser, elinks, because that’s what is available on this Redhat installation. Here is my example elinks command:

elinks -source 'http://10.1.10.15:9090/plugins/restapi/userservice?type=add&secret=SecretPass&username='$user'&password='$pass'&groups='$grup'&name='$frst' '$last'&email='$mail

   I also do not get any status errors from the command, so I have to believe it is at least contacting the server.  I am following the documentation here:

http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#using-the-plugin

So, any suggestions?

  • David

Hey,

at first I would recommend you, not to use the deprecated part of userservice inside of rest api.

But nevertheless I guess you need just enable the REST API and set the Authentication to Secret in the Web Openfire Admin Interface (Server Settings > Rest API).

First, thanks for your quick response. The RestApi settings page has Enabled checked, and

Secret key auth checked, with my key in the Secret key box. Nothing else is checked.

As described in the question that I submitted, the following elinks command was sent to the server:

elinks -source ‘http://10.1.10.15:9090/plugins/restapi/userservicetype=add&secret=notrealkeyhere &username=’$user’&password=’$pass’&groups=’$grup’&name=’$frst’ ‘$last’&email=’$mail

Filling in test values, it looks like this:

elinks -source ‘http://10.1.10.15:9090/plugins/restapi/userservicetype=add&secret=notrealkeyhere &username=aaatest.user&password=pwpass&groups=group2&name=user&email=aaatest.use r@whatever.comt.user&password=pwpass&groups=group2&name=user&email=aaatest.user@whatever.com’

Running this command returned no response, and the status (error) value was 0 (meaning no error). I was expecting a , like the userservice calls, but got nothing.

  • David

Sorry, but in that last reply, the editor did not handle that long string very well.

The expansion of the elinks command ends with ‘whatever.com’. The extra line

that repeats some of the parameters was not in my original response.

Hey, I just figured out that the documentation was wrong.

The path should contain the version. So the right URL would be http://localhost:9090/plugins/restapi/v1/userservice?type=add&secret=2Bk5RXeh&us ername=testuser with the /v1/ after the restapi

Awesome! That worked. This will save me a world of grief. Thanks much.

  • David

Thanks, again. When you get a chance, please update the README for RestApi on the plugins page.