{"record":{"id":"46479571aec40df9","repo":"pentaho/pentaho-kettle","slug":"statuscode","errorCode":null,"errorMessage":"StatusCode: ","messagePattern":"StatusCode: ","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/entries/http/JobEntryHTTP.java","lineNumber":685,"sourceCode":"    HttpResponse response = null;\n    if ( !Utils.isEmpty( proxyHostname ) ) {\n      HttpHost target = new HttpHost( uri.getHost(), uri.getPort(), uri.getScheme() );\n      // Create AuthCache instance\n      AuthCache authCache = new BasicAuthCache();\n      // Generate BASIC scheme object and add it to the local auth cache\n      BasicScheme basicAuth = new BasicScheme();\n      authCache.put( target, basicAuth );\n      // Add AuthCache to the execution context\n      HttpClientContext localContext = HttpClientContext.create();\n      localContext.setAuthCache( authCache );\n      response = client.execute( target, httpRequestBase, localContext );\n    } else {\n      response = client.execute( httpRequestBase );\n    }\n    responseStatusCode = response.getStatusLine().getStatusCode();\n\n    if ( HttpStatus.SC_OK != responseStatusCode ) {\n      throw new KettleException( \"StatusCode: \" + responseStatusCode );\n    }\n\n    if ( log.isDetailed() ) {\n      logDetailed( BaseMessages.getString( PKG, \"JobHTTP.Log.StartReadingReply\" ) );\n    }\n\n    logBasic( BaseMessages.getString( PKG, \"JobHTTP.Log.ReplayInfo\",\n      response.getEntity().getContentType(),\n      response.getLastHeader( HttpHeaders.DATE ).getValue() ) );\n\n    // Read the result from the server...\n    return response.getEntity().getContent();\n  }\n\n  @Override\n  public boolean evaluates() {\n    return true;\n  }","sourceCodeStart":667,"sourceCodeEnd":703,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/entries/http/JobEntryHTTP.java#L667-L703","documentation":"Thrown by JobEntryHTTP's execute logic when the HTTP response status code is not 200 (HttpStatus.SC_OK). The status code is appended to the message. The library deliberately treats any non-OK status as a failure of the HTTP job entry, since the entry's contract is to fetch a resource successfully.","triggerScenarios":"Running the HTTP job entry (client.execute returning a response whose getStatusLine().getStatusCode() != 200) — e.g. 404 for a wrong URL, 401/403 for missing credentials, 500 from the server, 301/302 when redirects are disabled.","commonSituations":"Target URL mistyped or resource moved; authentication headers missing or expired; server-side error at the remote endpoint; proxy/firewall returning error pages; redirect responses when follow-redirects is off.","solutions":["Read responseStatusCode in the message and address it: fix the URL for 404, add auth headers for 401/403, fix server-side issues for 5xx.","Verify the resource exists and is reachable from the Pentaho server's network (proxy/firewall).","Enable/verify redirect handling in the HTTP client configuration if the target moved.","If the endpoint legitimately returns non-200, wrap the entry with error handling in the job flow instead of failing."],"exampleFix":"// before: URL returns 404\nString url = \"http://host/old-path/file.xml\";\n// after: corrected URL\nString url = \"http://host/new-path/file.xml\";\n// and/or add auth header before executing\nhttpGet.setHeader(\"Authorization\", \"Bearer \" + token);","handlingStrategy":"validation","validationCode":"// pre-flight check before running the HTTP entry\nHttpURLConnection c = (HttpURLConnection) new URL(url).openConnection();\nc.setRequestMethod(\"HEAD\");\nc.setConnectTimeout(5000);\nint code = c.getResponseCode();\nif (code != 200) throw new IllegalStateException(\"Pre-flight failed with HTTP \" + code + \" for \" + url);","typeGuard":null,"tryCatchPattern":"try {\n  result = jobEntry.execute(prevResult, nr);\n} catch (KettleException e) {\n  if (e.getMessage().startsWith(\"StatusCode: \")) {\n    int code = Integer.parseInt(e.getMessage().substring(\"StatusCode: \".length()));\n    logError(\"HTTP entry got status \" + code);\n    result.setResult(false);\n  }\n}","preventionTips":["Verify the target URL with curl/HEAD before wiring it into the entry.","Configure required auth headers and keep tokens fresh.","Ensure the Pentaho server can reach the host (proxy/firewall rules).","Enable redirect following if the endpoint returns 3xx.","Add success-condition/error handling in the job flow for expected non-200s."],"tags":["http","network","job-entry","status-code"],"backgroundTag":"http-non-200-response","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}