2016-10-07 17 views
0

からパスワードを忘れた場合RestAPIこんにちは、私はhttps://forgerock.org/openam/doc/bootstrap/user-self-service-guide/index.html#configuring-forgotten-password問題のJava

にAPIを与えdocumentaion通過したが、ポスターや郵便配達から正常に動作しています。しかし、httpを使用してjavaから動作していない場合は、内部のサーバーが動作しています。何が問題だろうか? plsヘルプ。

public static void main(String a[]) throws IOException { 
    JSONObject data1 = new JSONObject(); 
    JSONObject data = new JSONObject(); 

    data.put("queryFilter", "mail eq '[email protected]'"); 
    data1.put("input", data); 
    System.out.println(data1); 

    Map<String, String> headers = new HashMap<String, String>(); 


     HttpURLConnection connection = null; 

    try { 

     URL obj = new URL("http://localhost:8080/sso/json/sample/selfservice" 
     + "/forgottenPassword?_action=submitRequirements"); 
     connection = (HttpURLConnection) obj.openConnection(); 
     connection.setRequestMethod("POST"); 
     connection.setDoInput(true); 
     connection.setDoOutput(true); 
     connection.setRequestProperty("Content-Type", "application/json"); 
     if (headers != null && headers.size() > 0) { 
      Iterator it = headers.entrySet().iterator(); 
      while (it.hasNext()) { 
       Map.Entry pair = (Map.Entry) it.next(); 
       connection.setRequestProperty((String) pair.getKey(), 
         (String) pair.getValue()); 
      } 
     } 
     // Send request 
     DataOutputStream dataOutputStream = new DataOutputStream(
       connection.getOutputStream()); 


     dataOutputStream.writeBytes(data1.toString()); 
     dataOutputStream.flush(); 
     dataOutputStream.close(); 

     // Get Response 
     System.out.println(connection.getResponseCode()); 
     System.out.println(connection.getResponseMessage()); 

     InputStream is = connection.getInputStream(); 
     BufferedReader rd = new BufferedReader(new InputStreamReader(is)); 
     String line; 

     StringBuilder response = new StringBuilder(); 
     while ((line = rd.readLine()) != null) { 
      response.append(line); 
      response.append('\r'); 
     } 
     rd.close(); 
     is.close(); 
     return response.toString(); 
    } catch (MalformedURLException e) { 
     LOG.info("Error in sendPost : MalformedURLException " + e); 
     throw e; 
    } catch (ProtocolException e) { 
     LOG.info("Error in sendPost : ProtocolException " + e); 
     throw e; 
    } catch (IOException e) { 
     e.printStackTrace(); 
     LOG.info("Error in sendPost : IOException " 
       + e.getLocalizedMessage()); 
     LOG.info("Error in sendPost : IOException " + e); 
     throw e; 
    } finally { 
     if (connection != null) { 
      connection.disconnect(); 
     } 
    }} 

答えて

0

私は、サポートされているロケールでリクエストにAccept-Languageヘッダーを設定する必要があると思います。