Project

General

Profile

PubSub Rest api problem

Avatar?id=6316&size=32x32

Tom Black
Added 12 months ago

I want to use PubSub Rest api,My tigase version is 7.1.3.
I get a error like this,when pubsub rest api call create-node method.
return

error code="401" type="auth" not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" error

I solved the problem like this, added the command init.properties config files.

--admins = admin@ital-dev3,http@Ubuntu-1604-xenial-64-minimal

Ubuntu-1604-xenial-64-minimal is my computer name.Why do I have to add it? However, the virtual host name is ital-dev3.I'm getting an error when I'm using a virtual host domain name.(http@ital-dev3)
The other problem is rest api works only in xml format.When I send the json format, response is 500 Internel Server Error.How do work json format?

HTTP URI: /rest/pubsub/pubsub.ital-dev3/create-node

{
 "node" : "example",
 "owner" : "admin@ital-dev3",
 "pubsub#node_type" : "leaf"
}
I set Http header value is `"Content-Type" application/json.`

Replies (7)

Added by Wojciech Kapcia TigaseTeam 11 months ago

Tom Black wrote:

I want to use PubSub Rest api,My tigase version is 7.1.3.
I get a error like this,when pubsub rest api call create-node method.
return

error code="401" type="auth" not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" error

I solved the problem like this, added the command init.properties config files.

--admins = admin@ital-dev3,http@Ubuntu-1604-xenial-64-minimal

Ubuntu-1604-xenial-64-minimal is my computer name.Why do I have to add it? However, the virtual host name is ital-dev3.I'm getting an error when I'm using a virtual host domain name.(http@ital-dev3)

It's because of internal Tigase architecture and how component interacts. In principle HTTP component executes command on PubSub component, but requires to be autorised to to that.
Instead of providing concrete names you can use variable: http@{clusterNode}

The other problem is rest api works only in xml format.When I send the json format, response is 500 Internel Server Error.How do work json format?

HTTP URI: /rest/pubsub/pubsub.ital-dev3/create-node

{
 "node" : "example",
 "owner" : "admin@ital-dev3",
 "pubsub#node_type" : "leaf"
}

I set Http header value is "Content-Type" application/json.

Ho do you exactly set the header? Are there any entries in server log (you could try adding http and pubsub to the debug configuration)

(1)
Avatar?id=6316&size=32x32

Added by Tom Black 11 months ago

Thanks for reply,I set the header like this,

I had changed the debug configuration for http and pubsub, I didnt seen any entries relative these components.

(1)

Added by Wojciech Kapcia TigaseTeam 11 months ago

Can you share you full init.properties file? Can you try interacting with pubsub using XMPP client (creating node, publication, etc.)?

Added by 连生 张 5 months ago

I want to use the PubSub Rest API, and my tigase version is 7.1.4.
I get this error when the pubsub rest API calls the create-node method.

(1)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam 5 months ago

You should be using pubsub.192.168.1.155 as the pubsub JID instead of pubsub@192.168.1.155.

Added by 连生 张 5 months ago

I revised it according to what you said, but there was a new mistake

Added by 连生 张 5 months ago

2019-01-08 16:37:08.620 [in_2-message-router]  MessageRouter.processPacket()  FINEST:   1. Packet will be processed by: pubsub@zhangliansheng, from=http@zhangliansheng/c64c75e8-f819-4cdd-ab49-03d8ffe19479, to=null, DATA=<iq type="set" xmlns="jabber:client" id="1cc9f38a-e62d-4ad6-8f01-7a028262a041" to="pubsub.192.168.1.155" from="http@zhangliansheng/c64c75e8-f819-4cdd-ab49-03d8ffe19479"><command node="create-node" xmlns="http://jabber.org/protocol/commands"><x type="submit" xmlns="jabber:x:data"><field var="node"><value>999999</value></field><field var="owner"><value>admin@192.168.1.155</value></field><field var="pubsub#node_type"><value>leaf</value></field></x></command></iq>, SIZE=464, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=ADMIN, TYPE=set



2019-01-08 16:43:05.837 [in_0-message-router]  MessageRouter.processPacket()  FINEST:   Processing packet: from=sess-man@zhangliansheng, to=c2s@zhangliansheng/192.168.1.155_5222_192.168.1.155_64831, DATA=<iq type="result" xmlns="jabber:client" id="HGXhn-153" to="zhangqi@192.168.1.155/Spark 2.8.3.960"><query xmlns="jabber:iq:private"><scratchpad xmlns="scratchpad:tasks"/></query></iq>, SIZE=182, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=result



2019-01-08 16:43:05.837 [in_0-c2s]         ConnectionManager.writePacketToSocket()  FINEST: c2s@zhangliansheng/192.168.1.155_5222_192.168.1.155_64831, type: accept, Socket: c2s@zhangliansheng/192.168.1.155_5222_192.168.1.155_64831 Socket[addr=/192.168.1.155,port=64831,localport=5222], jid: zhangqi@192.168.1.155/Spark 2.8.3.960, Writing packet: from=sess-man@zhangliansheng, to=c2s@zhangliansheng/192.168.1.155_5222_192.168.1.155_64831, DATA=<iq type="result" xmlns="jabber:client" id="HGXhn-153" to="zhangqi@192.168.1.155/Spark 2.8.3.960"><query xmlns="jabber:iq:private"><scratchpad xmlns="scratchpad:tasks"/></query></iq>, SIZE=182, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=result

    (1-7/7)