Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 6.1.1 CE GA2, 6.1.20 EE GA2
-
Fix Version/s: 6.1.1 CE GA2, 6.1.20 EE GA2
-
Component/s: API > Portal Service
-
Labels:None
-
Environment:Standalone REST client or Javascript client or Java client
-
Similar Issues:
Description
When you invoke a JSON service, it is necessary to pass all data as application/x-www-form-urlencoded. It is not possible to pass JSON object in the post body using application/json.
For example, if we have data like shown below,
var data = { "serviceMethodName" : "createBar", "servletContextName" : "test-json-portlet", "serviceParameters" : ["userId","userName"], "userId" : 10194, "userName" : "test" };
Then the following code does not work,
var url = "http://localhost:8080/api/json"; $.ajax({ type : "POST", url : url, contentType : "application/json; charset=utf-8", dataType : "json", headers : { "Authorization" : "Basic dGVzdEBsaWZlcmF5LmNvbTp0ZXN0" }, data : JSON.stringify(data), success : function(results) { console.log(results); } });

I have the fix and will send pull request soon.