2016-07-31 1 views
0
curl -D- -u fred:fred -X GET -H "Content-Type: application/json" http://kelpie9:8081/rest/api/2/issue/createmeta 

上記のカールを認証するためのhttpリクエストコード?アンドロイドのカールURLヘッダーの使い方

httpGet.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials("username:password"),HTTP.UTF_8, false)); 

これは間違いありませんか?エラーあなたのシーイングがあなたのcurlコマンドを実行した後にどのようなものです - 私は、出力

+0

Kandhasamyを取得しておりません。あなたの構文は大丈夫だと思われます。 –

+0

あなたの質問は以下の場合、問題の答えではない –

答えて

0

パブリック静的文字列のGetRequest(){

String countstring; 

    StringBuffer stringBuffer = new StringBuffer(""); 
    BufferedReader bufferedReader = null; 
    try { 
     HttpClient httpClient = new DefaultHttpClient(); 
     HttpGet httpGet = new HttpGet(); 

     URI uri = new URI("https://XXXXXXXXX.atlassian.net/rest/api/2/search?jql=status=open"); 
     httpGet.setURI(uri); 
     httpGet.addHeader(BasicScheme.authenticate(
       new UsernamePasswordCredentials("XXXXXX", "XXXXXXXXX"), 
       HTTP.UTF_8, false)); 

     HttpResponse httpResponse = httpClient.execute(httpGet); 
     InputStream inputStream = httpResponse.getEntity().getContent(); 
     bufferedReader = new BufferedReader(new InputStreamReader(
       inputStream)); 

     String readLine = bufferedReader.readLine(); 
     while (readLine != null) { 
      stringBuffer.append(readLine); 
      stringBuffer.append("\n"); 
      readLine = bufferedReader.readLine(); 
     } 
    } catch (Exception e) { 
     // TODO: handle exception 
     System.out.println("oindi"); 
    } 

    finally { 
     if (bufferedReader != null) { 
      try { 
       bufferedReader.close(); 
      } catch (IOException e) { 
       // TODO: handle exception 
      } 
     } 
    } 

    System.out.println("numbers3 :"+ stringBuffer.toString()); 

    JSONObject entries=null; 
    String jsontext; 
    jsontext=stringBuffer.toString(); 
    int india = jsontext.length(); 
    System.out.println("india" +india); 
    try { 
     entries = new JSONObject(jsontext); 


     int lat = entries.getInt("total"); 

     System.out.println("latttttttttttttttt"+lat); 

     countstring=String.valueOf(lat); 

     System.out.println("numbers4"+ countstring); 

    } 
    catch (JSONException w) 
    { 
     w.printStackTrace(); 
     System.out.println("Exceptionnnnnnnnnn 3"); 
     // Toast.makeText(getApplicationContext(), "Account details are incorrect", Toast.LENGTH_SHORT).show(); 
    } 

    return stringBuffer.toString(); 
} 
+0

上記のコードは... throwing exceptionとinteger indiaが0である –

+0

コードダンプではなく将来の読者のために、 –

関連する問題