title: Angular 6 - get csv response from httpClient
body: <p>Can any one please give an example of fetching application/octet-stream response from angular 6 httpClient. I am using the below code and it doesn't work ( I get unknown error - 401 response) - </p>
  
  <pre><code>import { saveAs } from 'file-saver';
  
  getJobOutput() {
      this.workflowService.fetchOutput(this.jobId,this.outputId).subscribe((response : any) =&gt; { // download file
                var blob = new Blob([response.blob()], {type: 'application/octet-stream'});
      var filename = 'file.csv';
      saveAs(blob, filename);
      });
     }
  </code></pre>
  
  <p>Service is as below - </p>
  
  <pre><code> fetchOutput(jobId : string, outputId) {
      var jobOutputURL = "myEnpoint";
       var params = this.createHttpAuthorization(jobOutputURL,"GET");
       params["format"] = "csv";
      const options = {
              headers: new HttpHeaders( { 'Content-Type': 'application/octet-stream',
                                          'Accept' : 'application/octet-stream',
                                          'Access-Control-Allow-Origin' : '*'}
                                      )};
  
      var endpoint = `${jobOutputURL}?oauth_consumer_key=${params["oauth_consumer_key"]}&amp;oauth_signature_method=${params["oauth_signature_method"]}&amp;oauth_nonce=${params["oauth_nonce"]}&amp;oauth_timestamp=${params["oauth_timestamp"]}&amp;oauth_version=1.0&amp;format=${params["format"]}&amp;oauth_signature=${params["oauth_signature"]}`;
  return this.httpClient.get(endpoint, {...options, responseType: 'blob'});
    }
  </code></pre>