CodeIgniter Forums
unable to download the csv file in via rest api - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: unable to download the csv file in via rest api (/showthread.php?tid=80394)



unable to download the csv file in via rest api - 2k10cs86 - 10-27-2021

Hello,
I'm trying to download the CSV content file using the REST API in Codeigniter 4 but it not working, I'm fetching the data from the database which I need to download via rest API.
In the controller I found this:
return $this->response->download('test.csv', $data); // $data is string

Front in angular:
const headers = new HttpHeaders().append('responseType', 'blob');
this.http.get(path, { headers }).subscribe(
  (res) => {},
  (error) => {console.error(error)}
);

But not working, am I missing something?

Please guide me.


RE: unable to download the csv file in via rest api - Aakriti - 11-05-2023

It appears there's an issue with downloading the CSV file via the REST API. Troubleshooting the API call or checking permissions could help resolve this download problem.


RE: unable to download the csv file in via rest api - ozornick - 11-05-2023

Maybe CORS block? See browser console
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS


RE: unable to download the csv file in via rest api - Darsh - 11-13-2023

Unable to download a CSV file via the REST API.

The present implementation is having trouble getting CSV files using the REST API. Incorrect endpoint configurations, authentication issues, or server-side issues are all possible causes. It is critical to evaluate and troubleshoot the code in order to discover and address the root cause, guaranteeing that users have a smooth file download experience. Regular testing and monitoring will aid in maintaining the API's dependability.