0

Hope you all are doing great, I have a basic query about "How to get rid off this error urllib2.HTTPError: HTTP Error 404", what is this error is all about? I searched found that meaning the resource can't be found, Python internal error. I also searched some of the pages to match the actual error but seems its only showing "urllib2.HTTPError: HTTP Error 404:" nothing found anything like that.

Tried below, but no help. import requests requests.get(url)

What am doing is below:

import urllib2
import urlopen
import time
import sys
import re


JENKINS_BASE = "url"
JENKINS_JOB = "my jenkin job path/"
agents_list = []
start = 0   #
job_number = 'lastBuild'  # Get the last build
cont = True   # This semaphore will be used to indicate whether or not to read more data

while cont:
    response = urllib2.urlopen(
   '{base}/{job}/{job_number}'
   '/logText/progressiveText?start={start}'.format(
    base=JENKINS_BASE, job=JENKINS_JOB,
    job_number=job_number, start=start
     )

)

Expected, that I shouldn't get the error: urllib2.HTTPError: HTTP Error 404

Muthu Kumar
  • 885
  • 2
  • 14
  • 25
Python
  • 17
  • 1
  • 4
  • in general it means that such a page does not exist. Try putting it in the URL manually and see whether you can definitely reach it? – VnC May 07 '19 at 14:13
  • HTTP 404 means that the resource is not found on the server == the url is (most likely) incorrect and the error is not with Python. Try printing the url and resolve it in other ways (browser, curl, wget). – Ahlqvist May 07 '19 at 14:13
  • 4xx error is client error -- meaning the error is on your side(e.g., wrong URL, wrong parameters etc..) And as the folks above says, your specific error means the URL you gave doesn't exist on the server. However, some application will also return that error if you lack enough permissions. I think you need to check how to programmatically access your jenkins server. I believe you are missing authentication pieces in your request -- unless your jenkins is white open without the need to authenticate. – congbaoguier May 07 '19 at 14:17
  • Hope the accepted answer here can do your justice: https://stackoverflow.com/questions/39623786/how-to-authenticate-in-jenkins-while-remotely-accessing-its-json-api – congbaoguier May 07 '19 at 14:20
  • okie Thanks for all the comments guys, problem with URL, fixing url resolve the issue – Python May 07 '19 at 14:39

0 Answers0