Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function testBodyJavaAdapter(){
- alert("HI")
- var baseUrlJavaAdapter="/adapters/JavaAdapterTest/api/postHelloUserBody";
- var req = new WLResourceRequest(baseUrlJavaAdapter, WLResourceRequest.POST);
- var json={
- first:"Nazmul",
- middle:"Hasan",
- last:"Prince"
- }
- req.setHeader("Content-Type", "application/json");
- req.send(json).then(function(resp){
- alert("Success");
- $("#showInfoDiv").html(resp.responseText);
- })
- }
- @Path("/api")
- @OAuthSecurity(enabled=false)
- public class JavaAdapterTestResource {
- static Logger logger = Logger.getLogger(JavaAdapterTestResource.class.getName());
- //Define the server api to be able to perform server operations
- WLServerAPI api = WLServerAPIProvider.getWLServerAPI();
- @POST
- @Consumes("application/json")
- @Path("/postHelloUserBody")
- public String postHelloUserBody(@HeaderParam("Content-Type") String type, JSONObject json) throws IOException{
- return "Hello " + json.get("first") + " " + json.get("middle") + " " + json.get("last");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement