0

There is such a request. But the browser does not start downloading the file? How to do it? I tried to substitute different parameters Header

public GetJobsListExcel(jobs: JobViewModel[]) {
    let JobIds: number[] = [];
    jobs.forEach(x => JobIds.push(x.JobId));


    let body = JSON.stringify({ jobIds: JobIds });
    let headers = new Headers({ 'Content-Type': 'application/json' , 'cache-control': 'no-cache' , 'postman-token': '9135e481-df69-b870-4f72-92873c1fd7de' });
    let options = new RequestOptions({ headers: headers });
    let url = 'http://localhost:32001/api/job/jobs-list-excel';

    return this.http.post(url, body, options)
        .map(res => res.json().data)
        .catch(this.handleError)
        .toPromise() 
}
Valitskiy Dmitriy
  • 160
  • 1
  • 3
  • 9
  • You are only downloading data/content through ajax request. Browser won't start downloading anything, you are only getting content of the file in javascript context. You can implement a method which will interpret this content (blob) to be created as an url and can be downloaded using an anchor tag. – Animator May 26 '17 at 07:04
  • A similar question was asked [here](https://stackoverflow.com/questions/26606234/angularjs-file-download-through-ajax). – Animator May 26 '17 at 07:05

0 Answers0