Help me please!!! rbv_api.sendHttpPost cannot send to POST p

Posted by tanagorns@progress.in.th on 07-May-2015 00:20

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!!

All Replies

Posted by Anoop Premachandran on 07-May-2015 00:42

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

documentation.progress.com/.../index.html

Posted by tanagorns@progress.in.th on 07-May-2015 02:10

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);

Posted by Anoop Premachandran on 07-May-2015 02:53

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

This thread is closed