Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » OM2M » How to add a string to the body of contentInstance?
How to add a string to the body of contentInstance? [message #1742283] Thu, 01 September 2016 12:36 Go to next message
Son Duong is currently offline Son DuongFriend
Messages: 60
Registered: June 2016
Member
Hello all,

assume that I have a string like:

String bodyContent =
"<con>
&lt;obj>
&lt;str name=&quot;appId&quot;val=&quot;APP&quot;/>
&lt;str name=&quot;category&quot; val=&quot;temperature &quot;/>
&lt;int name=&quot;data&quot; val=&quot;20&quot;/>
&lt;int name=&quot;unit&quot; val=&quot;celsius&quot;/>
&lt;/obj>
</con>"


And I would like to create inside of the DATA container an contentInstance whose body is the above string.
I tried the following:

String targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + actuatorId + "/" + DATA;
ContentInstance cin = new ContentInstance(); 		  
cin.setContent(bodyContent);
cin.setContentInfo(MimeMediaType.OBJ);
RequestSender.createContentInstance(targetId, cin);


And this is my result, the content body was not shown as a table like usual:
https://s14.postimg.org/kdukr3ye9/Unbenannt.png

Can anyone help me where did I do wrong here?

Thank you very much!
Son
Re: How to add a string to the body of contentInstance? [message #1742853 is a reply to message #1742283] Thu, 08 September 2016 08:52 Go to previous messageGo to next message
Dorian Kurzaj is currently offline Dorian KurzajFriend
Messages: 16
Registered: May 2016
Junior Member
Hello,

Did you try with the String :

String bodyContent =
"&lt;obj>
&lt;str name=&quot;appId&quot;val=&quot;APP&quot;/>
&lt;str name=&quot;category&quot; val=&quot;temperature &quot;/>
&lt;int name=&quot;data&quot; val=&quot;20&quot;/>
&lt;int name=&quot;unit&quot; val=&quot;celsius&quot;/>
&lt;/obj>"


Because it seems, according to you picture that there is an extra <con> tag, which is not needed.

Regards,
Dorian
Re: How to add a string to the body of contentInstance? [message #1742857 is a reply to message #1742853] Thu, 08 September 2016 09:03 Go to previous messageGo to next message
Son Duong is currently offline Son DuongFriend
Messages: 60
Registered: June 2016
Member
Hi Dorian,

I also tried without of the <con> tag but still no success Sad

Regards,
Son
Re: How to add a string to the body of contentInstance? [message #1742860 is a reply to message #1742857] Thu, 08 September 2016 09:18 Go to previous message
Dorian Kurzaj is currently offline Dorian KurzajFriend
Messages: 16
Registered: May 2016
Junior Member
And when you do a GET request with a REST client on this resource, do you retrieve the value you wanted ? Because, it may just be the display in the debug interface which does not work as you expect (maybe also try to put the value by replacing all the &lt; and &quot; by < and ").

[Updated on: Thu, 08 September 2016 09:19]

Report message to a moderator

Previous Topic:How to start the plugin automatically?
Next Topic:where is the OM2M-libs.rar
Goto Forum:
  


Current Time: Fri Apr 19 20:26:29 GMT 2024

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

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

Back to the top