Hi Guy!!
In Rollbase Private Cloud V.3.2. I tried to rbv_api.sendHttpPost in Trigger for Send to mysite but POST parameter cannot send to mysite . Why!!
EX: This is my Rollbase code.
-----------------------------------------------------
var params = {"power":"123","total":"092"};
var headers = {
"Content-Type":"application/x-www-form-urlencoded"
};
var test = rbv_api.sendHttpPost("http://mysite/service/?serv=saving&api=inputPayment", params,headers,false);
rbv_api.println(test);
-----------------------------------------
This code is debug getParameter In my JAVA page
Enumeration<String> paramNames = request.getParameterNames();
while(paramNames.hasMoreElements()) {
String paramName = (String)paramNames.nextElement();
out.print(paramName + " : ");
String paramValue = request.getParameter(paramName);
out.println(paramValue);
out.println("--------------------");
}
------------------------------------------------
This is debug display....
--------------------------------------
This is JAVA code Return value
String result = request.getParameter ("power");
out.println(result);
---------------------------------------------------------
ReTurn value is "null"
Thanks for Answer
Best regards
Boy!!
sendHttpPost method always POSTs data as multipart/form-data requests. It cannot do request of form application/x-www-form-urlencoded. So what is happening here is that header is set as application/x-www-form-urlencoded but request body is of multi-part format as you see in debug display. Your Server reads the header and tries to parse the body as a form-urlencoded string. This fails and so you get null.
What you should do is use rbv_api.sendJSONRequest
I tried multipart/form-data but it cannot work.
EX:
var params = {"power":"123","total":"092"};
var headers = {
"Content-Type":"multipart/form-data"
};
var test = rbv_api.sendHttpPost("http://Mysite/service/?serv=saving&api=inputPayment", params,headers,false);
rbv_api.println(test);
When you are sending data as multipart/form-data, request.getParameterxx() methods will not work.
You have 2 options here
1. Change Server - Use request.getParts()
2. Change Client - Use rbv_api.sendJSONRequest in Rollbase