Introducing restAPI plugin for Openfire

The Ignite Realtime Community is pleased to announce the 1.0.0 release of the REST API plugin for Openfire. This plugin is being developed by community member @Redeyes. This plugin merges and replaces the functionality found in the “MUC Service Plugin” and the REST functionality found in the “User Service Plugin”. This new plugin allows for REST style administration of Openfire.

The current feature list, taken from the README file includes:

  • Get overview over all or specific user and to create, update or delete a user
  • Get overview over all user roster entries and to add, update or delete a roster entry
  • Add user to a group and remove a user from a group
  • Lockout or unlock the user (enable / disable)
  • Get overview over all or specific system properties and to create, update or delete system property
  • Get overview over all or specific chat room and to create, update or delete a chat room

Please report any issues or feature ideas for this plugin in the Community Forums.

2 Likes

Every time return openfire login page in response.

Examples

Header: Authorization: Basic YWRtaW46MTIzNDU=

**GET ** http://example.org:9090/plugins/restapi/v1/users/testuser/groups

Which version of Openfire do you use?

I could not reproduce that with 3.9.3

I solved my problem using openfire admin username and password.

I am getting login page because of wrong authentication detail in restAPI.

1 Like

It seem to be that your JSON payload is wrong.

Here is a example:

POST to http://localhost:9090/plugins/restapi/v1/users

Headers

Authorization: secretKey

Content-Type: application/json

Payload

{

“username”: “admin1”,

“password”: “p4ssword”,

“name”: “Administrator”,

"email": "email"

}

I can not follow you, could you please provide me your HTTP request with the payload (XML / JSON)? (which one is working and which one not)

Regarding: Add user using restapi-users - Doesn’t Work

Could you provide me the JSON payload? (The raw view not the form view).

I guess the problem is there, because it create not a valid JSON format.

Additionally you need to add “Content-Type: application/json” to the header (Additionally to Authorization) such in example:

Header: Authorization: Basic YWRtaW46MTIzNDU=
Header: Content-Type: application/json

POST http://example.org:9090/plugins/restapi/v1/users

{
   "username": "admin",
   "password": "p4ssword",
   "name": "Administrator",
   "email": "admin@example.com"
}

Very nice and about time there was an api to manage users

Thanks !

At this point, it is giving me unauthorized error. Headers are same as it is like above. Don’t know what is wrong.

I was having a hard time not able to call the APIs as it was returning 403 every time inspite of installing the plugin . Then I found the following tab to configure the REST API behavior under : server -> Server Settings tab -> Rest api option on left side bar or directly from http://localhost:9090/plugins/restapi/rest-api.jsp

@

Just enabling the HTTP basic auth from here makes all the APIS work . Shared to help any future users .

1 Like

How can search users with email id is exist or not with any uesr

I use rest api plugin in openfire and want to use in my development app but need to verify email is exist with any user or not. Becasue as I search everywhere is only search by username not by email.

Suppose I have follwoing example
http://xx.xx.xx.xx:9090/plugins/restapi/v1/users

Authorization: s3cretKey
Accept application/json

If any mentod or possibilities then let me know

I went thru all documentation for REST API.
REST API Plugin Readme

I created a users with custom properties such as country in key / value pair. Can you able to provide REST API to search by those key value pairs instead of just username? Also add users with key value pairs that are not Group Names?

I was able to successfully create user, delete user, add budyy relationship with groups and reciprocate. But I am not able to delete the roster entry using the api. I get the following 302 response code.

2016-05-02 10:55:40.893 %-5L [OpenfireScriptRunner] - {‘Authorization’: ‘Basic YWRtaW46YWRtaW4=’}

2016-05-02 10:55:40.894 %-5L [OpenfireScriptRunner] - 1fauserb@lchi093136-7

2016-05-02 10:55:40.894 %-5L [OpenfireScriptRunner] - http://localhost:9090/plugins/restapi/v1/users/auser/roster/1fauserb@lchi093136- 7

2016-05-02 10:55:40.894 %-5L [OpenfireScriptRunner] - Failed (302: Found)

Is there something I need to do differently besides calling DELETE and the url as shown in the examples?

Which Openfire version do you use?

I am using Openfire 3.9.3

The problem is, that the name contains an @ . Upgrade openfire to at least 3.10 or avoid the @ character.

Thats the jid for the roster item not the name. Should i just pass the name without the @lchi093136-7 identifier

yes.

Got this error

2016-05-02 13:36:52.536 %-5L [OpenfireScriptRunner] - {‘Authorization’: ‘Basic YWRtaW46YWRtaW4=’}

2016-05-02 13:36:52.536 %-5L [OpenfireScriptRunner] - 1fauserb

2016-05-02 13:36:52.537 %-5L [OpenfireScriptRunner] - http://localhost:9090/plugins/restapi/v1/users/auser/roster/1fauserb

2016-05-02 13:36:52.537 %-5L [OpenfireScriptRunner] - Failed (500: Internal Server Error)

2016.04.29 08:49:19 org.jivesoftware.openfire.nio.ConnectionHandler - ConnectionHandler reports unexpected exception for session: (SOCKET, R: /10.40.122.25:38243, L: /10.40.110.184:5223, S: 0.0.0.0/0.0.0.0:5223)

java.lang.IllegalArgumentException

at java.nio.Buffer.position(Unknown Source)

at org.apache.mina.filter.support.SSLHandler.messageReceived(SSLHandler.java:313)

at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:392)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)

at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)

at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived (AbstractIoFilterChain.java:499)

at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)

at org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(Abstra ctIoFilterChain.java:293)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.j ava:228)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcesso r.java:198)

at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProce ssor.java:45)

at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProce ssor.java:485)

at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

2016.05.02 13:36:52 org.jivesoftware.openfire.plugin.rest.exceptions.RESTExceptionMapper - RosterItemNotFound: Roster Item could not deleted with ressource 1fauserb