Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Kapua » POST data to kapua(problem with sending data to kapua over http post request described in swagger)
POST data to kapua [message #1777562] Thu, 30 November 2017 11:01 Go to next message
Dusan Zivkovic is currently offline Dusan ZivkovicFriend
Messages: 3
Registered: November 2017
Junior Member
Hello,
I have problem to send data to kapua over HTTP post request. So far i successfully used this routes:

- POST /authentication/user Authenticate an user
- GET /{scopeId}/data/metrics Gets the MetricInfo list in the scope
-GET /{scopeId}/data/messages/{datastoreMessageId} Gets an DatastoreMessage

Route i have problem to use:
- POST /{scopeId}/data/messages Stores a new KapuaDataMessage
This is json that should be sent in body:

{
"scopeId": "string",
"position": {
"timestamp": "2017-11-30T10:51:02.090Z",
"precision": 0,
"status": 0,
"longitude": 0,
"latitude": 0,
"altitude": 0,
"heading": 0,
"speed": 0,
"satellites": 0
},
"payload": {
"body": [
"string"
],
"metrics": {}
},
"id": "string",
"clientId": "string",
"deviceId": "string",
"receivedOn": "2017-11-30T10:51:02.090Z",
"sentOn": "2017-11-30T10:51:02.090Z",
"capturedOn": "2017-11-30T10:51:02.090Z",
"channel": {
"semanticParts": [
"string"
]
}
}
For some values I'm not sure what goes there
- id, body
Problem is that every attempt respond with this
type":"throwableInfo",
"httpErrorCode":500,
"kapuaErrorCode":
"SEVERE_INTERNAL_ERROR",
"stackTrace":"javax.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type\n\ta and 50more lines of text
Re: POST data to kapua [message #1777981 is a reply to message #1777562] Thu, 07 December 2017 09:43 Go to previous messageGo to next message
Milan Ggg is currently offline Milan GggFriend
Messages: 28
Registered: March 2017
Junior Member
Kapua was built as cloud platform to work wit Eclipse Kura framework( ofc and to work with other languages also, but Kura and Kapua works best :) ). Kura has KuraPayload class for sending data to cloud, and Kapua expects KuraPayload message structure. You can find KuraPayload class on this link :
https://github.com/eclipse/kura/blob/develop/kura/org.eclipse.kura.api/src/main/java/org/eclipse/kura/message/KuraPayload.java
And as for your example, I can provide you with document that contains dummy data JSON response from kapua, so you can see how it looks. I am not sure, also, that all API methods works. Most of POST methods for sending data to Kapua didn't work on previous versions. :)

Also, take a look on : https://github.com/ctron/kapua-gateway-client

* In JSON that I attached, I put ***** characters instead of some personal data.

Regards (Pozdrav :) ),

Milan
Re: POST data to kapua [message #1777982 is a reply to message #1777562] Thu, 07 December 2017 09:43 Go to previous messageGo to next message
Milan Ggg is currently offline Milan GggFriend
Messages: 28
Registered: March 2017
Junior Member
Kapua was built as cloud platform to work wit Eclipse Kura framework( ofc and to work with other languages also, but Kura and Kapua works best :) ). Kura has KuraPayload class for sending data to cloud, and Kapua expects KuraPayload message structure. You can find KuraPayload class on this link :
https://github.com/eclipse/kura/blob/develop/kura/org.eclipse.kura.api/src/main/java/org/eclipse/kura/message/KuraPayload.java
And as for your example, I can provide you with document that contains dummy data JSON response from kapua, so you can see how it looks. I am not sure, also, that all API methods works. Most of POST methods for sending data to Kapua didn't work on previous versions. :)

Also, take a look on : https://github.com/ctron/kapua-gateway-client

* In JSON that I attached, I put ***** characters instead of some personal data.

Regards (Pozdrav :) ),

Milan
Re: POST data to kapua [message #1778047 is a reply to message #1777982] Fri, 08 December 2017 14:44 Go to previous messageGo to next message
Dusan Zivkovic is currently offline Dusan ZivkovicFriend
Messages: 3
Registered: November 2017
Junior Member
Hello Milan (Pozdrav MIlane :) ), thanks for answering,
I have kura plugin(edited "example publisher" plugin) connected to Kapua. Kura plugin is sending data to Kapua and it's subscribed to other data on kapua. I want to post data from frontend application to channel where Kura plugin is subscribed. This will allow me to send some configuration data from fronted application to kura plugin. APi is explained in swagger that comes with kapua (kapuaIP:8081/doc/), and json i wrote comes from there. I have those response you attached on this route: GET /{scopeId}/data/metrics Gets the MetricInfo list in the scope.
I have used data from:
GET /{scopeId}/data/metrics and
POST /authentication/user
for details needed for POST /{scopeId}/data/messages but I'm still not sure what id and body values should be. You also mentioned that there is possibility that this route is not working.
Re: POST data to kapua [message #1778166 is a reply to message #1778047] Mon, 11 December 2017 12:58 Go to previous messageGo to next message
Milan Ggg is currently offline Milan GggFriend
Messages: 28
Registered: March 2017
Junior Member
The thing is that API is working good, but there ain't method for storing data to Kapua and to forward it to message broker, so it will not be visible in console . (I tried that with mqtt libraries in NodeJS and Python, and data is stored but in back-end database).
API is not written for that, only for all kind of querry messages, authentication, etc.
For storing data to kapua from non - Kura application, you will need some mqtt client ( paho maybe) for connection with broker in order to send data to Elasticsearch. Or kapua-gateway-client sdk ( I sent you link in previous post).
Regards,
Milan
Re: POST data to kapua [message #1778174 is a reply to message #1778166] Mon, 11 December 2017 13:28 Go to previous messageGo to next message
Dusan Zivkovic is currently offline Dusan ZivkovicFriend
Messages: 3
Registered: November 2017
Junior Member
Hmm, I'm a bit confused, I can read data sent from kapua using API on this routes:
- GET /{scopeId}/data/metrics Gets the MetricInfo list in the scope
-GET /{scopeId}/data/messages/{datastoreMessageId} Gets an DatastoreMessage
And also there is route for posting data over API explained in swagger
POST /{scopeId}/data/messages Stores a new KapuaDataMessage
If you agree i would like to continu this conversation in private chat, but I haven't found chat between forum members.

[Updated on: Fri, 15 December 2017 15:50]

Report message to a moderator

Re: POST data to kapua [message #1797980 is a reply to message #1777562] Fri, 09 November 2018 13:45 Go to previous message
Güven Yücetürk is currently offline Güven YücetürkFriend
Messages: 1
Registered: November 2018
Junior Member
Hi All,

I am having exactly the same problem as above @Dusan Zivkovic mentioned.

I know it doesn't make to create a fake data message and post Kapua, but I am trying to run a simulation and for that, I would like use a script and post bunch of generated messages to Kapua via Rest API.

Any help?

Sincerely,

Guven
Previous Topic:Replacing ActiveMQ
Goto Forum:
  


Current Time: Mon Nov 19 23:38:52 GMT 2018

Powered by FUDForum. Page generated in 0.02491 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top