I'm using IBM Worklight 6.1 for my mobile app project. How can I send post values in adapter?
function getUsername(userAlias,locale) {
path = "rest-rib/service/Login/login_username";
var input = {
method : 'post',
returnedContentType : 'json',
path : path
};
return WL.Server.invokeHttp(input);
}
You should read about HTTP adapters.
More:
The below simple POST
example is based on this POST
method example from W3C Schools.
Adapter XML:
<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="PostExample"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>PostExample</displayName>
<description>PostExample</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>www.w3schools.com</domain>
<port>80</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="sendParams"/>
</wl:adapter>
Adapter implementation:
function sendParams() {
path = "tags/demo_form_method_post.asp";
var input = {
method : 'post',
path: path,
parameters: {fname: 'idan', lname: 'adar' }
};
return WL.Server.invokeHttp(input);
}