Reputation: 47
I've created a java adapter "myadapterjava" on mobile first 7.0. below the procedure
@POST
@Path("/myprocedurejava")
@Produces("application/json")
@Consumes("application/json")
public JSONObject myprocedure(String param){
JsonObject value = Json.createObjectBuilder()
.add("firstName", "John")
.add("lastName", "Smith");
return value ;
}
I'm trying to call it from javascript using:
var urlToInvoke = '/adapters/myadapterjava/myprocedurejava';
var timeOut = 20000;
var param = JSON.stringify(mydata);
var procedure = WLResourceRequest.POST;
var resourceRequest = new WLResourceRequest(urlToInvoke, procedure, timeOut);
resourceRequest.send(param).then(function(data) {
console.log("OKOKOK");
}, function(error) {
console.log("KOKOKOKO");
});
In this way I have the onError call and the status of the error is 415. Where I'm wrong?
Thanks
Upvotes: 0
Views: 146
Reputation: 421
Try changing the @Produces to @Produces(MediaType.APPLICATION_JSON)
Upvotes: 3