[iotcon] Representation in Request may be null.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 15 Feb 2016 09:20:29 +0000 (10:20 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 16 Feb 2016 10:30:55 +0000 (19:30 +0900)
Change-Id: I9f7b1bccc80d3e77a40548d9eb5ffa2815161937
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/iotcon/iotcon_api.js
src/iotcon/iotcon_utils.cc

index 288447b9370a2032b4f3c8278be519fc6e836fff..2e20b6c8eef44b3d8341172f92ba88e9f216c577 100644 (file)
@@ -266,6 +266,8 @@ function Request(data) {
 
   if (data.representation) {
     data.representation = createRepresentation(data.representation);
+  } else {
+    data.representation = null;
   }
 
   if (data.options) {
index 6f2a99f95c637de6290f171c16e313acbf804bbd..762f2cb3f601db92ec63b9552840c880bd7a4bc1 100644 (file)
@@ -443,12 +443,16 @@ common::TizenResult IotconUtils::RequestToJson(iotcon_request_h request,
     if (!result) {
       LogAndReturnTizenError(result, ("iotcon_request_get_representation() failed"));
     }
-    picojson::value v{picojson::object{}};
-    result = RepresentationToJson(representation, &v.get<picojson::object>());
-    if (!result) {
-      LogAndReturnTizenError(result, ("RepresentationToJson() failed"));
+    if (representation) {
+      picojson::value v{picojson::object{}};
+      result = RepresentationToJson(representation, &v.get<picojson::object>());
+      if (!result) {
+        LogAndReturnTizenError(result, ("RepresentationToJson() failed"));
+      }
+      out->insert(std::make_pair(kRepresentation, v));
+    } else {
+      LoggerD("Request doesn't have representation.");
     }
-    out->insert(std::make_pair(kRepresentation, v));
   }
 
   {