Angular 6/7 - Error downloading file - message“:”Http failure during parsing forAngular EXCEPTION: No provider for HttpHuge number of files generated for every Angular projectAngular 4 HttpModule How to Return a File From Get RequestAngular 2 HttpErrorResponse during parsing the responseAngular HTTP request error: “post valid request”Http failure during parsing Angular 5Downloading files with Angular 2 and .Net Core APIAngular http POST to get JWT token returns 200ok with parsing errorAngular Download Large blobsHow to get body from HttpErrorResponse in Angular 6?
Should I ask for a raise one month before the end of an internship?
Get contents before a colon
Inspiration for failed idea?
How to reply to people who accuse me of putting people out of work?
How to say "I only speak one language which is English" in French?
STM32 cannot reach individual registers and pins as PIC
Can a network vulnerability be exploited locally?
How did medieval manors handle population growth? Were there room for more fields to be ploughed?
Drawing probabilities on a simplex in TikZ
Can I get a PhD for developing educational software?
How do Barton (Hawkeye/Ronin) and Romanov (Black Widow) end up on the Benatar on Morag in 2014?
Was the six engine Boeing-747 ever thought about?
Why is there not a willingness from the world to step in between Pakistan and India?
Journal published a paper, ignoring my objections as a referee
Notice period 60 days but I need to join in 45 days
Are there any to-scale diagrams of the TRAPPIST-1 system?
Looking for a plural noun related to ‘fulcrum’ or ‘pivot’ that denotes multiple things as crucial to success
What does GDPR mean to myself regarding my own data?
What's the point of fighting monsters in Zelda BotW?
Stolen MacBook should I worry about my data?
Why is the Grievance Studies affair considered to be research requiring IRB approval?
Alternatives to Network Backup
Why does this London Underground poster from 1924 have a Star of David atop a Christmas tree?
How do you say "half the time …, the other half …" in German?
Angular 6/7 - Error downloading file - message“:”Http failure during parsing for
Angular EXCEPTION: No provider for HttpHuge number of files generated for every Angular projectAngular 4 HttpModule How to Return a File From Get RequestAngular 2 HttpErrorResponse during parsing the responseAngular HTTP request error: “post valid request”Http failure during parsing Angular 5Downloading files with Angular 2 and .Net Core APIAngular http POST to get JWT token returns 200ok with parsing errorAngular Download Large blobsHow to get body from HttpErrorResponse in Angular 6?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to download an attachment directly from my webapi using angular httpmodule. I've tried to change the responseType for 'blob', 'text' and 'arraybuffer' as angular documentation describes, but angular http module always returns an error in parse of response.
Note: If I call the api outside of angular (new browser tab) the file is downloaded correctly (<a href="fileLink" target="_blank"</a>
), but I do not want to use this because I use JWT instead cookies, so the token is not send in requests outside from angular (I could pass jwt token as a param for the external call, but this sounds like an anti pattern)
Basically I just want to do an http call which returns an file (e.g excel, pdf, png) and then download it and save in the browser, but an error happens when angular http parse the response (the subscribe function is not even called). Maybe is something wrong with my response?
Here'is service http call code:
downloadDocument(fileName: string): Observable<any>
return this.http.post<any>(`/MYAPIROUTE/$fileName`,
responseType: 'blob' //note: i've tried blob,text and arraybuffer
);
This is my component code: (//NOTE: The subscribe is not being called due an error in http parse.)
this.documentFileService.downloadDocument(fileName).subscribe((res) =>
console.log('start download:',res);
const data = res;
const blob = new Blob([data], type: 'application/octet-stream' );
this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(blob));
, error =>
console.log('download error:', JSON.stringify(error));
, () =>
console.log('Completed file download.')
);
Maybe is something wrong with my http response (missing headers, etc?) even though it's working 100% for http calls outside from angular?
This is my response: (The response data it's the file by itself).
Thanks in advance.
angular
add a comment |
I am trying to download an attachment directly from my webapi using angular httpmodule. I've tried to change the responseType for 'blob', 'text' and 'arraybuffer' as angular documentation describes, but angular http module always returns an error in parse of response.
Note: If I call the api outside of angular (new browser tab) the file is downloaded correctly (<a href="fileLink" target="_blank"</a>
), but I do not want to use this because I use JWT instead cookies, so the token is not send in requests outside from angular (I could pass jwt token as a param for the external call, but this sounds like an anti pattern)
Basically I just want to do an http call which returns an file (e.g excel, pdf, png) and then download it and save in the browser, but an error happens when angular http parse the response (the subscribe function is not even called). Maybe is something wrong with my response?
Here'is service http call code:
downloadDocument(fileName: string): Observable<any>
return this.http.post<any>(`/MYAPIROUTE/$fileName`,
responseType: 'blob' //note: i've tried blob,text and arraybuffer
);
This is my component code: (//NOTE: The subscribe is not being called due an error in http parse.)
this.documentFileService.downloadDocument(fileName).subscribe((res) =>
console.log('start download:',res);
const data = res;
const blob = new Blob([data], type: 'application/octet-stream' );
this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(blob));
, error =>
console.log('download error:', JSON.stringify(error));
, () =>
console.log('Completed file download.')
);
Maybe is something wrong with my http response (missing headers, etc?) even though it's working 100% for http calls outside from angular?
This is my response: (The response data it's the file by itself).
Thanks in advance.
angular
add a comment |
I am trying to download an attachment directly from my webapi using angular httpmodule. I've tried to change the responseType for 'blob', 'text' and 'arraybuffer' as angular documentation describes, but angular http module always returns an error in parse of response.
Note: If I call the api outside of angular (new browser tab) the file is downloaded correctly (<a href="fileLink" target="_blank"</a>
), but I do not want to use this because I use JWT instead cookies, so the token is not send in requests outside from angular (I could pass jwt token as a param for the external call, but this sounds like an anti pattern)
Basically I just want to do an http call which returns an file (e.g excel, pdf, png) and then download it and save in the browser, but an error happens when angular http parse the response (the subscribe function is not even called). Maybe is something wrong with my response?
Here'is service http call code:
downloadDocument(fileName: string): Observable<any>
return this.http.post<any>(`/MYAPIROUTE/$fileName`,
responseType: 'blob' //note: i've tried blob,text and arraybuffer
);
This is my component code: (//NOTE: The subscribe is not being called due an error in http parse.)
this.documentFileService.downloadDocument(fileName).subscribe((res) =>
console.log('start download:',res);
const data = res;
const blob = new Blob([data], type: 'application/octet-stream' );
this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(blob));
, error =>
console.log('download error:', JSON.stringify(error));
, () =>
console.log('Completed file download.')
);
Maybe is something wrong with my http response (missing headers, etc?) even though it's working 100% for http calls outside from angular?
This is my response: (The response data it's the file by itself).
Thanks in advance.
angular
I am trying to download an attachment directly from my webapi using angular httpmodule. I've tried to change the responseType for 'blob', 'text' and 'arraybuffer' as angular documentation describes, but angular http module always returns an error in parse of response.
Note: If I call the api outside of angular (new browser tab) the file is downloaded correctly (<a href="fileLink" target="_blank"</a>
), but I do not want to use this because I use JWT instead cookies, so the token is not send in requests outside from angular (I could pass jwt token as a param for the external call, but this sounds like an anti pattern)
Basically I just want to do an http call which returns an file (e.g excel, pdf, png) and then download it and save in the browser, but an error happens when angular http parse the response (the subscribe function is not even called). Maybe is something wrong with my response?
Here'is service http call code:
downloadDocument(fileName: string): Observable<any>
return this.http.post<any>(`/MYAPIROUTE/$fileName`,
responseType: 'blob' //note: i've tried blob,text and arraybuffer
);
This is my component code: (//NOTE: The subscribe is not being called due an error in http parse.)
this.documentFileService.downloadDocument(fileName).subscribe((res) =>
console.log('start download:',res);
const data = res;
const blob = new Blob([data], type: 'application/octet-stream' );
this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(blob));
, error =>
console.log('download error:', JSON.stringify(error));
, () =>
console.log('Completed file download.')
);
Maybe is something wrong with my http response (missing headers, etc?) even though it's working 100% for http calls outside from angular?
This is my response: (The response data it's the file by itself).
Thanks in advance.
angular
angular
edited Mar 27 at 21:14
R. Richards
16.3k9 gold badges44 silver badges50 bronze badges
16.3k9 gold badges44 silver badges50 bronze badges
asked Mar 27 at 21:11
Lucas SantosLucas Santos
3091 gold badge3 silver badges13 bronze badges
3091 gold badge3 silver badges13 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386525%2fangular-6-7-error-downloading-file-messagehttp-failure-during-parsing-for%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386525%2fangular-6-7-error-downloading-file-messagehttp-failure-during-parsing-for%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown