0
    URL url = new URL("http://nvmbd1bkb150v03.rjil.ril.com/system/ws/v11/gh/search/?portalId=400100000001003&usertype=customer&$format=json");
    String payload="portalId=400100000001003&Q1-1-1000000931=1000000919&usertype=customer&%24format=json";
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    connection.setRequestProperty("session_id", session_id);
    connection.setRequestProperty("Accept", "application/json");
    connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
    OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
    //writer.write(payload);
    writer.close();
    BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    while ((line = br.readLine()) != null) {
            jsonString.append(line);
    }
    //br.close();
    //connection.disconnect();
} catch (Exception e) {
        throw new RuntimeException(e.getMessage());
}
out.println(jsonString.toString());

This is all my code. I want to read that web service but it is giving me error. Please help.

Markus W Mahlberg
  • 19,711
  • 6
  • 65
  • 89
sumit
  • 1
  • 1
  • java.lang.RuntimeException: Server returned HTTP response code: 400 for URL: http://nvmbd1bkb150v03.rjil.ril.com/system/ws/v11/gh/search/?portalId=400100000001003&usertype=customer&$format=json at org.apache.jsp.GuidedHelpAnswers_jsp._jspService(GuidedHelpAnswe...This is the error – sumit Dec 25 '14 at 12:31
  • Any one have any alternative code for resolving this? – sumit Dec 25 '14 at 12:36
  • @sumit: please add the _complete_ error message to your question by using the edit link. As a side note: the link gives a 400 error, thrown in case there is something wrong with the request. Please read the API docs carefully. – Markus W Mahlberg Dec 25 '14 at 12:43
  • SEVERE: Servlet.service() for servlet [jsp] in context with path [/Egain_Test] threw exception [An exception occurred processing JSP page /GuidedHelpAnswers.jsp at line 55 52: //br.close(); 53: //connection.disconnect(); 54: } catch (Exception e) { 55: throw new RuntimeException(e.getMessage()); 56: } 57: out.println(jsonString.toString()); Stacktrace:with root cause java.lang.RuntimeException:Server returned HTTP response code: 400 for URL: http://nvmbd1bkb150v03.rjil.ril.com/system/ws/v11/gh/search/?portalId=400100000001003&usertype=customer&$format=json – sumit Dec 25 '14 at 12:45
  • When I try this same web service with same session-id in firefox plugin then it is giving output even without payload also.....But when I am trying this code with same session_id then it is not working... – sumit Dec 25 '14 at 12:48
  • this post might be of help http://stackoverflow.com/questions/19671317/400-bad-request-http-error-code-meaning – SummerCode Dec 25 '14 at 12:52
  • How can I retrieve session-id from response header in the same code.......anyone have any idea? – sumit Dec 25 '14 at 13:15
  • When I am doing connection.getHeaderFields() in above code then session id is coming as null....please give some alternative code if possible....I want to get session-id of the same web service call....Thanks – sumit Dec 25 '14 at 13:30

0 Answers0