title: Calling WEB API to download excel file
body: <p>below is C# WEB API Code to generate Excel :</p>
  
  <pre><code>public class FileExportController : ApiController
  {
  
      [HttpGet]
      public HttpResponseMessage Get()
      {
          var callerContext = CallerContext.DefaultCallerContext;
          ReportingInput userInput = new ReportingInput();
          userInput.ClientOneCode = "AVON";
          string handle = Guid.NewGuid().ToString();
          var @event = new GetJobReprotDataBlEvent(callerContext, userInput);
          WebApiApplication.ApplicationInitializerObj.EventBus.Publish(@event);
          XLWorkbook wb = new FileExportEngine().ExportExcel(@event.ReportData); //this is returning XLWorkbook
          string fileName = "JobReport_" + DateTime.Now.ToString("yyyy -MM-dd HH':'mm':'ss") + ".xlsx";
          using (MemoryStream memoryStream = new MemoryStream())
          {
              wb.SaveAs(memoryStream);
  
              var result = new HttpResponseMessage(HttpStatusCode.OK)
              {
                  Content = new ByteArrayContent(memoryStream.ToArray())
              };
              result.Content.Headers.ContentDisposition =
                  new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
                  {
                      FileName = fileName
                  };
              result.Content.Headers.ContentType =
                  new MediaTypeHeaderValue("application/octet-stream");
  
              return result;
          }
  
      }
  </code></pre>
  
  <p>When I call this API from browser, I am able to generate excel file.
  <a href="http://localhost/ETLScheduler/api/FileExport" rel="nofollow noreferrer">http://localhost/ETLScheduler/api/FileExport</a> -- this is working when hit direct in browser</p>
  
  <p>Now I want to use consume this API in angular 5 application.I have a button.On click button I call the component method downloadFile() to download the file.
  Below is the code :</p>
  
  <pre><code>downloadReport() {     
      this._service.downloadJobReport('AVON');
  }
  </code></pre>
  
  <p>where downloadJobReport() is in my service file as below :</p>
  
  <pre><code>downloadJobReport(clientCode: string) {
      return this._http.get(APIs.downloadJobReport);
  }
  </code></pre>
  
  <p>When I am running the application and click on Download button, I am getting nothing, I mean file is not downloading. Can anyone have idea,how should I update my angular code to consume the API.</p>
  
  <p>Thanks in advance.</p>