IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Pub.client:http Method Delete Rest service with request body as payload Json

webMethods Community Member

webMethods Community MemberTue September 27, 2022 03:24 AM

  • 1.  Pub.client:http Method Delete Rest service with request body as payload Json

    Posted Tue September 27, 2022 03:22 AM

    Hi Guys,

    This is my experience to thank you, My Software AG Designer 10.3 on pub.client:http I can’t pass body on Method delete ,This is a known scenario and Integration Server doesn’t accept request body for HTTP DELETE Method.

    i use Java Service like this so HTTP method DELETE can use payload json

    1. The first i imported the httpclient jar.
    2. the second i use java source code :
    		String resultJson = null;
    String rescode = null;
    String jsonInputString = jsonBodyString;
    try {
    
    url = new URL (uri);
    
    HttpURLConnection con = (HttpURLConnection)url.openConnection();
    con.setRequestMethod("DELETE");
    
    con.setRequestProperty("Content-Type", "application/json; utf-8");
    con.setRequestProperty("Accept", "application/json");
    
    con.setDoOutput(true);
    try(OutputStream os = con.getOutputStream()){
    byte[] input = jsonInputString.getBytes("utf-8");
    os.write(input, 0, input.length);			
    }
    
    int code = con.getResponseCode();
    rescode = String.valueOf(code);
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))){
    StringBuilder response = new StringBuilder();
    String responseLine = null;
    while ((responseLine = br.readLine()) != null) {
    response.append(responseLine.trim());
    }
    resultJson = response.toString();
    }
    
    } catch (Exception e) {
    e.printStackTrace();
    }
    

    :star_struck:thanks for tutorials/PostJSONWithHttpURLConnection.java at master · eugenp/tutorials · GitHub

    did anyone solve it this way…
    sorry if there is a mistake :smile:

    Thanks & Regards
    Maman H


    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: Pub.client:http Method Delete Rest service with request body as payload Json

    Posted Tue September 27, 2022 03:24 AM

    thanks for the directions


    #webMethods
    #Integration-Server-and-ESB