title: Jenkins REST API to get job and job console log
body: <p>How to get the details of the job along with it console output using Jenkins REST API</p>
  
  <p>example of builds</p>
  
  <p><a href="https://i.stack.imgur.com/Unsls.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Unsls.png" alt="Builds"></a></p>
  
  <p>console output:</p>
  
  <p><a href="https://i.stack.imgur.com/xJ1XI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xJ1XI.png" alt="console Output for the build"></a></p>
  
  <p>I am using following commands to get the path of console log</p>
  
  <p>echo $JENKINS_HOME/jobs/$JOB_NAME/builds/${BUILD_NUMBER}/log</p>
  
  <p>echo $BUILD_URL/consoleText</p>
  
  <p>It would provide the path to console log</p>
  
  <p><a href="http://localhost:8080/job/Echo/25//consoleText" rel="noreferrer">http://localhost:8080/job/Echo/25//consoleText</a></p>
  
  <p>but if i try to get the data from it using c#.net it would through me a exception</p>
  
  <p>I am using following code to get the data</p>
  
  <pre><code> public string Download_Contents(string URI)
      {
          string Data = string.Empty;
          try
          {
              using (var wc = new System.Net.WebClient())
                  Data = wc.DownloadString(URI);
          }
          catch (Exception ex)
          {
              throw ex;
          }
          return Data;
      }
  </code></pre>
  
  <p>Exception:</p>
  
  <p><a href="https://i.stack.imgur.com/Cifta.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Cifta.png" alt="Exception"></a></p>