I tried to call rest service using http adapter, but got unsupported media type exception.
My adapter and server side code is as follows
var invocationData = { adapter : 'MyHttpAdapter', procedure : 'myAdapterProcedure', parameters : [myJSONObject] };
WL.Client.invokeProcedure(invocationData, {
onSuccess : success,
onFailure : failure
});
function myAdapterProcedure(prarams) {
var input = {
method : 'put',
returnedContentType : 'json',
path : 'mobile/rest/notes/getMyWebData',
parameters : prarams
};
return WL.Server.invokeHttp(input);
}
server side:
@PUT
@Path("addNotes")
@Consumes("application/json")
@Produces("application/json")
public String addNotes(MyNotes pVo) throws Exception
{
System.out.println("1231231" + pVo);
return pVo;
}
Detailed exception: Failed to parse JSON string Apache Tomcat/6.0.35 - Error report
HTTP Status 415 - Unsupported Media Type
type Status report
message Unsupported Media Type
description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method (Unsupported Media Type).
Apache Tomcat/6.0.35
FWLSE0101E: Caused by: [project GMobile]java.io.IOException: Unexpected character '<' on line 1, column 1 com.worklight.common.log.filters.ErrorFilterTried with Put, Post method invocations and got the same exception. tried with '@Consumes({ MediaType.APPLICATION_JSON }) on server method still get the same error. Can anyone let me know what am I missing here...
Found the same issue here, without the solution. ref: How to send the JSON data in rest web services?