Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » OM2M » JSON content "con" attribute in ContentInstance
JSON content "con" attribute in ContentInstance [message #1787232] Tue, 22 May 2018 13:44 Go to next message
Arnaud Moncade is currently offline Arnaud MoncadeFriend
Messages: 4
Registered: May 2018
Junior Member
Hello,

I created an AE named SAMPLE_AE, with a DATA container in it. Then I want to send a JSON contentInstance under the DATA container. So I post an HTTP Request with the following content:

 {
   "m2m:cin": {
     "cnf": "application/json",
     "con": {
     	"appId": "SAMPLE_AE",
     	"category": "sample_category",
     	"value": "1"
    	}
   }
 }


But here is the response I get :

Status : 201 created 
{
    "m2m:cin": {
        "rn": "cin_490476127",
        "ty": 4,
        "ri": "/mn-cse/cin-490476127",
        "pi": "/mn-cse/cnt-644912348",
        "ct": "20180522T133731",
        "lt": "20180522T133731",
        "st": 0,
        "cnf": "application/json",
        "cs": 0,
        "con": ""
    }

}

The JSON content is ignored. It works only if I set a single string (e.g "con":"1"). I found a workaround using oBIX :

 {
   "m2m:cin": {
     "cnf": "application/obix:0",
     "con": "<obj>
     <str name=\"appId\" val=\"SAMPLE_AE\"/>
     <str name=\"category\" val=\"sample_category\"/>
     <int name=\"value\" val=\"1\"/>
     </obj>"
   }
 }


This works but is less easy to integrate in my solution.

Am I doing anything wrong?
Re: JSON content "con" attribute in ContentInstance [message #1787271 is a reply to message #1787232] Wed, 23 May 2018 04:01 Go to previous messageGo to next message
Fariz Alemuda is currently offline Fariz AlemudaFriend
Messages: 9
Registered: July 2016
Junior Member
can u give a try with this one?
 {
   "m2m:cin": {
     "cnf": "application/json",
     "con": {
     	\"appId\": \"SAMPLE_AE\",
     	\"category\": \"sample_category\",
     	\"value\": \"1\"
    	}
   }
 }

[Updated on: Wed, 23 May 2018 04:10]

Report message to a moderator

Re: JSON content "con" attribute in ContentInstance [message #1787292 is a reply to message #1787271] Wed, 23 May 2018 08:58 Go to previous message
Arnaud Moncade is currently offline Arnaud MoncadeFriend
Messages: 4
Registered: May 2018
Junior Member
Thanks for your answer. I just tried that and I get a 400 - Bad Request : Error in provided content error.

Here is the log from the MN-CSE in this case :

[INFO] - org.eclipse.om2m.binding.http.RestHttpServlet
Content type headers: application/json;ty=4
[INFO] - org.eclipse.om2m.binding.http.RestHttpServlet
Header value: application/json
[INFO] - org.eclipse.om2m.binding.http.RestHttpServlet
Header value: ty=4
[INFO] - org.eclipse.om2m.binding.http.RestHttpServlet
Accept header: application/json
[INFO] - org.eclipse.om2m.core.router.Router
Received request in Router: RequestPrimitive [operation=1,
 to=/mn-cse/mn-name/SAMPLE_AE/DATA,
 from=admin:admin,
 resourceType=4,
 content= {
   "m2m:cin": {
     "cnf": "application/json",
     "con": {
        \"appId\": \"SAMPLE_AE\",
        \"category\": \"sample_category\",
        \"value\": \"1\"
        }
   }
 }
,
 filterCriteria=org.eclipse.om2m.commons.resource.FilterCriteria@f4d5de,
 returnContentType=application/json,
 requestContentType=application/json,
 queryStrings={}]

[INFO] - org.eclipse.om2m.core.router.Router
Request handling in the current CSE: /mn-cse/mn-name/SAMPLE_AE/DATA
[INFO] - org.eclipse.om2m.core.router.Router
ResourceController to be used [ContentInstanceController]
line 5:6 no viable alternative at character '\'
line 11:0 mismatched character '<EOF>' expecting '"'
line 0:-1 mismatched input '<EOF>' expecting '}'
[ERROR] - org.eclipse.om2m.datamapping.jaxb.Mapper
JAXB unmarshalling error!
javax.xml.bind.UnmarshalException
 - with linked exception:
[Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Previous Topic:CoAP between App and in-cse
Next Topic:Using CoAP based applications (Copper vs Erbium)
Goto Forum:
  


Current Time: Tue Nov 13 19:51:57 GMT 2018

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

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

Back to the top