Load contact list CSV to JS app

I'm going to load a contact list to a JS based application. The getContactlistsContactlistIdExport method gives me the contact list URI. When I paste this URI into the address field in the browser then I am able to retrive the contact list CSV as downloaded file. If I use the same address in AJAX query the server returns a piece of HTML document instead. I was looking through a server response but I have no idea how to pick a real CSV address. Is there any trick to load a contact list CSV into a JS variable - without server-side code?

Thanks

The download links are authenticated, so it needs to use the existing authenticated session (or log into a new one) in order for the download request to succeed. The HTML is most likely the login page you are seeing.

Dariusz, in the case Adam response is not clear to you, you just need to add the "Authorization" header with your session token to be able to retrieve the CSV programatically.

Best Regards,

Raphael Barreiros

Hi, indeed I was wondering what to do with the login page in JS code. Thanks guys. I will check out you advices later.