Posting data object with MQTT [message #1783097] |
Wed, 07 March 2018 21:01 |
Jairo Ariza Messages: 9 Registered: March 2018 |
Junior Member |
|
|
Hello.
In the rest tutorial shows how to post data in the data container http://127.0.0.1:8080/~/in-cse/in-name/MY_SENSOR/DATA using xml content
<m2m:cin xmlns:m2m="http://www.onem2m.org/xml/protocols">
<cnf>message</cnf>
<con>
<obj>
<str name="appId" val="MY_SENSOR"/>
<str name="category" val="temperature "/>
<int name="data" val="27"/>
<int name="unit" val="celsius"/>
</obj>
</con>
</m2m:cin>
or with json
{
"m2m:cin": {"cnf":"message",
"con":"<obj>
<str name=\"appId\" val=\"MY_SENSOR\"/>
<str name=\"category\" val=\"temperature \"/>
<int name=\"data\" val=\"27\"/>
<int name=\"unit\" val=\"Farenheit\"/>
</obj>"
}
}
When I use mqtt to do the same operation with this payload:
payload6="""{"m2m:rqp": {
"m2m:fr" : "admin:admin",
"m2m:to" : "/in-cse/in-name/MY_SENSOR/DATA",
"m2m:op" : 1,
"m2m:rqi": 123454,
"m2m:pc": {
"m2m:cin": {"cnf":"message",
"con":"<obj>
<str name=\"appId\" val=\"MY_SENSOR\"/>
<str name=\"category\" val=\"temperature \"/>
<int name=\"data\" val=\"27\"/>
<int name=\"unit\" val=\"Farenheit\"/>
</obj>"
}
},
"m2m:ty": 4}}"""
I get this error:
{
"m2m:rsp" : {
"m2m:rsc" : 4000,
"m2m:pc" : "Invalid content provided in request primitive",
"m2m:to" : "Sensor_MQTT",
"m2m:fr" : "/in-cse"
}
}
But if I sent a simple pc with this payload:
payload6="""{"m2m:rqp": {
"m2m:fr" : "admin:admin",
"m2m:to" : "/in-cse/in-name/MY_SENSOR/DATA",
"m2m:op" : 1,
"m2m:rqi": 123454,
"m2m:pc": {
"m2m:cin": {"cnf":"message",
"con":"66 C"
}
},
"m2m:ty": 4}}"""
The instance is successfully created.
how can I successfully create a object data instance with mqtt?
Thank for your help.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04191 seconds