vahith  
                (vahith)
               
                 
              
                  
                    February 23, 2015, 11:56am
                   
                   
              1 
               
             
            
              hi, 
i am trying to create an index through url without using crul command and 
API,but it giving bad request, 
this is code snippet which i am using
public void sendPost() throws Exception {
     
    String url = "http://localhost:9200/product/apparel/300";
    URL obj = new URL(url);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    //add reuqest header 
    con.setRequestMethod("POST");
    //con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
    //String urlParameters = "type=slide";
    // Send post request
    con.setDoOutput(true);
    
    int responseCode = con.getResponseCode();
    System.out.println("\nSending 'POST' request to URL : " + url);
    //System.out.println("Post parameters : " + urlParameters);
    System.out.println("Response Code : " + responseCode);
    BufferedReader in = new BufferedReader(
            new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer response = new StringBuffer();
    while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
    }
    in.close();
    //print result
    System.out.println(response.toString());
}
 
could you suggest me what  i am doing wrong in this code..
-- 
vahith
-- 
You received this message because you are subscribed to the Google Groups "elasticsearch" group. 
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com . 
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5ea36f46-606d-402d-b14e-d74a6285b4e9%40googlegroups.com . 
For more options, visit https://groups.google.com/d/optout .
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    February 23, 2015,  4:01pm
                   
                   
              2 
               
             
            
              Wondering what you are trying to do here. Why not using elasticsearch Java API?
Still, some comments:
You are using POST instead of PUT 
We don’t know what you are sending to elasticsearch. 
We don’t know what response give elasticsearch.
-- 
David Pilato | Technical Advocate | Elasticsearch.com  
@dadoonet  https://twitter.com/dadoonet  | @elasticsearchfr  https://twitter.com/elasticsearchfr  | @scrutmydocs  https://twitter.com/scrutmydocs 
Le 23 févr. 2015 à 12:56, Vahith vahith@gmail.com  a écrit :
hi, 
i am trying to create an index through url without using crul command and API,but it giving bad request, 
this is code snippet which i am using
public void sendPost() throws Exception {
     
    String url = "http://localhost:9200/product/apparel/300";
    URL obj = new URL(url);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    //add reuqest header 
    con.setRequestMethod("POST");
    //con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
    //String urlParameters = "type=slide";
    // Send post request
    con.setDoOutput(true);
    
    int responseCode = con.getResponseCode();
    System.out.println("\nSending 'POST' request to URL : " + url);
    //System.out.println("Post parameters : " + urlParameters);
    System.out.println("Response Code : " + responseCode);
    BufferedReader in = new BufferedReader(
            new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer response = new StringBuffer();
    while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
    }
    in.close();
    //print result
    System.out.println(response.toString());
}
 
could you suggest me what  i am doing wrong in this code..
-- 
vahith
-- 
You received this message because you are subscribed to the Google Groups "elasticsearch" group. 
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com  mailto:elasticsearch+unsubscribe@googlegroups.com . 
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5ea36f46-606d-402d-b14e-d74a6285b4e9%40googlegroups.com  https://groups.google.com/d/msgid/elasticsearch/5ea36f46-606d-402d-b14e-d74a6285b4e9%40googlegroups.com?utm_medium=email&utm_source=footer . 
For more options, visit https://groups.google.com/d/optout  https://groups.google.com/d/optout .
 
-- 
You received this message because you are subscribed to the Google Groups "elasticsearch" group. 
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com . 
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/91235915-5B46-428E-9DB1-4E067918FDA3%40pilato.fr . 
For more options, visit https://groups.google.com/d/optout .