отдых службы возврат 204 вместо 200 - PullRequest
0 голосов
/ 29 октября 2018

У меня есть служба отдыха в том же домене https://iconfig -sit.abc.com / iconfigadmin / api / config-category / ISSICT / ISSICE: ICEQA: ICEUI / configuration / .... Когда я запускаю это в браузере, он работает нормально и возвращает 200 кода вместе с данными. но когда я звоню в коде Java, он возвращает 204, никаких данных ... не уверен, где проблема? вероятно, нужно установить больше заголовка, но какой не уверен. ниже код.

public Map<String, String> iconfig() throws Exception {
        GetMethod getMethod=null;
        Map<String, String> filesList1 = new LinkedHashMap<>();
        try{
            NTCredentials credentials = new NTCredentials("user","password","","domain");
            HttpClient httpClient = new HttpClient();
            httpClient.getState().setCredentials(AuthScope.ANY, credentials);
            //httpClient.getParams().setAuthenticationPreemptive(true);
            //httpClient.getState()         
            String serviceListQuery = "https://iconfig-sit.abc.com/iconfigadmin/api/config-category/ISSICT/ISSICE:ICEQA:ICEUI/configuration/oporders_bod_mismatch-source-grid";

            System.out.println("List file query " + serviceListQuery );
            getMethod = new GetMethod(serviceListQuery);
            getMethod.addRequestHeader("Access-Control-Allow-Credentials","true");
            getMethod.addRequestHeader("Access-Control-Allow-Origin","*");
            getMethod.addRequestHeader("Accept","application/json");
            getMethod.setRequestHeader("Content-Type", "application/json");          
            getMethod.setRequestHeader("prefer", "return=representation");
            //getMethod.setDoAuthentication(true);
            //getMethod.addRequestHeader("X-RequestDigest",formDigestValue);
            int uploadFileResponseCode = httpClient.executeMethod(getMethod);
            System.out.println(" List file query  " + uploadFileResponseCode );
            //if (uploadFileResponseCode == HttpStatus.OK.value()) {
                 byte[] responseBody = getMethod.getResponseBody();
                 System.out.println("Data" + responseBody );
                 JSONObject jsonObject = (JSONObject) new JSONParser().parse(responseBody);
                 if (jsonObject != null) {
                     JSONObject rootNode = (JSONObject) jsonObject.get("d");
                     JSONArray entries = (JSONArray) rootNode.get("results");
                 }          //} else {
                //logger.error("Unable to retrieve sharepoint documents url [" +  sharepointServiceUrl + "]. HTTP Status = " + status);             //}
        }catch(Exception e){
            System.out.println(e);
        }finally {          if (getMethod != null)
                getMethod.releaseConnection();      }
        return filesList1;
    }
...