Tell me how to send the Json request



I am sending the json request code give the error Is there any way how to send the json request with authentication.this Code give the Error in filenotfound "http://api.seatseller.travel/blockTicket"
//st = json object

       StringBuilder sb = new StringBuilder();  
         JSONObject jsonParam = st;//JSON 
         HttpURLConnection request=null; 
        OAuthConsumer consumer = new
DefaultOAuthConsumer("tOzL5hTkSz9KiA2RIAECW4g7Uq","cj8HLPmBKnRAsffLe5qpQIZ9Y");
        consumer.setTokenWithSecret(null, null); //i pass token as
access token as a null as my server dont need it.

        URL url = new URL("http://api.seatseller.travel/blockTicket");
          request = (HttpURLConnection) url.openConnection();
        request.setDoOutput(true);   
        request.setRequestMethod("GET"); 
        request.setUseCaches(false);  
        request.setConnectTimeout(10000);  
        request.setReadTimeout(10000);  
        request.setRequestProperty("Content-Type","application/json");
  

        request.setRequestProperty("Host", "android.schoolportal.gr");


        consumer.sign(request);
        request.connect();
        OutputStreamWriter out = new  
OutputStreamWriter(request.getOutputStream());
        out.write(jsonParam.toString());
        out.close();  
        int HttpResult =request.getResponseCode();  
        if(HttpResult ==HttpURLConnection.HTTP_OK){  
            BufferedReader br = new BufferedReader(new
InputStreamReader(  
                    request.getInputStream(),"utf-8"));  
            String line = null;  
            while ((line = br.readLine()) != null) {  
                sb.append(line + "
");  
            }  
            br.close();  

            System.out.println(""+sb.toString());  

        }else{  
                System.out.println(request.getResponseMessage());  
        }  
    } catch (MalformedURLException e) {  

             e.printStackTrace();  
    }  
    catch (IOException e) {  

        e.printStackTrace();  
        } 
     catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Related to : Tell me how to send the Json request

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .