Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] POST ECF Rest call

Hi All,

Can somebody tell me how to make a post request with  ECF Rest API.

My code looks like this:

IContainer container = ContainerFactory.getDefault().createContainer(REST_CONTAINER_TYPE, "");
IRemoteServiceClientContainerAdapter adapter = (IRemoteServiceClientContainerAdapter) container .getAdapter(IRemoteServiceClientContainerAdapter.class);
adapter.setResponseDeserializer(deserializer);
IRemoteCallParameter [] defaultParams = RemoteCallParameterFactory.createParameters("default","My Default Value");
HttpPostRequestType postRequest = new HttpPostRequestType();
IRemoteCallable callable = RestCallableFactory.createCallable(url, url,
   defaultParams, postRequest, IRestCall.DEFAULT_TIMEOUT);
IRemoteServiceRegistration registration = adapter.registerCallables(
new IRemoteCallable[] { callable }, null);
IRemoteService restClientService = adapter
.getRemoteService(registration.getReference());
return (T) restClientService.callSync(RestCallFactory.createRestCall(url));

I expected that data to be in the body of the request?

HttpPostRequestType postRequest = new HttpPostRequestType(<Map with params>); --> this line here puts the data that i want to transfer through the wire in the Request attributes  but its not safe operation i guess?
On the server i am using Restlet api to expose resltets.What is the generic way to make POST REST call.






Back to the top