{"record":{"id":"adb8a101c311d972","repo":"alibaba/DataX","slug":"response-status-code","errorCode":null,"errorMessage":"Response Status Code : ","messagePattern":"Response Status Code : ","errorType":"http","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/alibaba/datax/core/util/HttpClientUtil.java","lineNumber":125,"sourceCode":"    }\n\n    public static HttpDelete getDeleteRequest() {\n        return new HttpDelete();\n    }\n\n    public String executeAndGet(HttpRequestBase httpRequestBase) throws Exception {\n        HttpResponse response;\n        String entiStr = \"\";\n        try {\n            response = httpClient.execute(httpRequestBase);\n\n            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {\n                System.err.println(\"请求地址：\" + httpRequestBase.getURI() + \", 请求方法：\" + httpRequestBase.getMethod()\n                        + \",STATUS CODE = \" + response.getStatusLine().getStatusCode());\n                if (httpRequestBase != null) {\n                    httpRequestBase.abort();\n                }\n                throw new Exception(\"Response Status Code : \" + response.getStatusLine().getStatusCode());\n            } else {\n                HttpEntity entity = response.getEntity();\n                if (entity != null) {\n                    entiStr = EntityUtils.toString(entity, Consts.UTF_8);\n                } else {\n                    throw new Exception(\"Response Entity Is Null\");\n                }\n            }\n        } catch (Exception e) {\n            throw e;\n        }\n\n        return entiStr;\n    }\n\n    public String executeAndGetWithRetry(final HttpRequestBase httpRequestBase, final int retryTimes, final long retryInterval) {\n        try {\n            return RetryUtil.asyncExecuteWithRetry(new Callable<String>() {","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/core/src/main/java/com/alibaba/datax/core/util/HttpClientUtil.java#L107-L143","documentation":"HttpClientUtil.executeAndGet throws this when an HTTP response's status code is not 200. It first prints the request URI, method, and status code to stderr, aborts the request, then raises a generic Exception carrying the non-OK status code. Callers in DataX use it for admin/dataxservice REST calls and similar single-shot GET/POST helpers.","triggerScenarios":"Any executeAndGet call where the server returns 4xx/5xx or a redirect (3xx is also != SC_OK): wrong URL, expired credentials (401), missing resource (404), or server error (500). The preceding stderr line shows exactly which URI and status caused it.","commonSituations":"DataX service deploy with a misconfigured domain/port, an auth token expired, a proxy in front returning 403, or the target endpoint expecting a different path. Because 3xx fails too, a moved endpoint without redirect-following config also triggers it.","solutions":["Read the stderr line above the exception: it contains the exact request URL, method, and status code.","Map the status: 401/403 fix credentials or headers; 404 fix the URL path; 500 check the remote service logs.","curl the same URL from the DataX host to confirm network reachability and response body.","If the endpoint legitimately redirects or returns another success code, switch to a call path that accepts it (executeAndGet hard-codes SC_OK)."],"exampleFix":"// before\nString body = httpClientUtil.executeAndGet(new HttpGet(\"http://svc/api/job/42\"));\n// after: surface status explicitly and handle non-200\nHttpResponse resp = httpClient.execute(get);\nint code = resp.getStatusLine().getStatusCode();\nif (code != 200) throw new IOException(\"GET \" + get.getURI() + \" -> \" + code);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { String body = httpClientUtil.executeAndGet(req); } catch (Exception e) { if (e.getMessage().startsWith(\"Response Status Code\")) { /* inspect stderr log line for URI+code; branch on 401/404/5xx */ } throw e; }","preventionTips":["curl the target URL from the DataX host before starting jobs that depend on it.","Keep service URLs and tokens in config that is validated at deploy time; monitor for 401/403 drift."],"tags":["datax","http","rest-client","network"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}