From d7f875f9eced72c8cca12e80b57cbafa90052d94 Mon Sep 17 00:00:00 2001 From: sameeram Date: Mon, 27 Apr 2015 20:56:46 +0530 Subject: [PATCH] Added fix to obtain contents for request --- apps/publisher/modules/asset-api.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/publisher/modules/asset-api.js b/apps/publisher/modules/asset-api.js index c6e2cc6ca..c3c1f00b5 100644 --- a/apps/publisher/modules/asset-api.js +++ b/apps/publisher/modules/asset-api.js @@ -26,6 +26,7 @@ var result; var log = new Log('asset_api'); var exceptionModule = utils.exception; var constants = rxtModule.constants; + var CONTENT_TYPE_JSON = 'application/json'; /** * * @param fieldParam The raw string comes as field parameter of the request @@ -183,7 +184,22 @@ var result; for (var key in meta) { asset[key] = meta[key]; } - } + }; + var processContentType = function(contentType){ + var comps = contentType.split(';'); + return comps [0]; + }; + var processRequestBody = function(req,assetReq){ + var contentType = processContentType(req.getContentType()); + if(contentType !== CONTENT_TYPE_JSON){ + return assetReq; + } + var params = req.getContent(); + for(var key in params){ + assetReq[key] = params[key]; + } + return assetReq; + }; /** * api to create a new asset * @param options incoming values @@ -203,6 +219,7 @@ var result; var rxtManager = getRxtManager(session,options.type); var isLCEnabled = false; var isDefaultLCEnabled = false; + assetReq = processRequestBody(req,assetReq); if (request.getParameter("asset")) { asset = parse(request.getParameter("asset")); } else {