We are developing IONIC App using MFP7.1. We are trying to call REST webservice to get some data using HTTP Adapter.
I have the following adapter implementation file,
function getFeed(username,password) {
var data = {
"username" : username,
"password" : password
};
var input = {
method : 'post',
returnedContentType : 'plain',
path : 'PATH HERE',
body: {
content: data.toString(),
contentType: 'application/json; charset=utf-8;',
},
};
return WL.Server.invokeHttp(input);
}
And here is the adapter.xml,
<mfp:adapter name="http"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mfp="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>http</displayName>
<description>http</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>DOMAIN NAME HERE</domain>
<port>PORT NO HERE</port>
<connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
</connectionPolicy>
</connectivity>
<procedure name="getFeed"/>
</mfp:adapter>
We did the following to call the adapter within my ionic provider,
var resourceRequest = new WLResourceRequest("adapters/http/getFeed", WLResourceRequest.GET);
resourceRequest.setQueryParameter("params", "['username', 'password']");
resourceRequest.send().then(
function(response) {
alert('response '+JSON.stringify(response.responseText));
},
function(response) {
alert("HTTP Failure "+JSON.stringify(response));
}
);
I am getting the following error in the error log,
"errors\\":[],\\"info\\""statuscode\\":400}","responseJSON":{"statusReason":"Bad Request","responseHeaders":{"Transfer-Encoding":"chunked","Server":"Apache-Coyote/1.1","Connection":"close","Content-Type":"text/plain"},"isSuccessful":true,"Can not deserialize instance of WEBSERVICE entity here.User out of START_ARRAY token\\n at[Siyrce.org.apache.catal.inc.connector.......
Per the suggestion in the comments, try changing .toString()
to JSON.stringify
:
content:
JSON.stringify(data)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.