I have this in html:
Choose File handleFileInput(files: FileList) { const headers = new Headers({ 'Content-Type': 'multipart/form-data' }); var formData = new FormData(); formData.append("myFile", files.item[0]); this.api.postWithoutEntity('/socialintegration/callback/attachment', { recipientId: this.selected.custSocId, file: formData }).subscribe(); this.upload = false; }
but im getting this: Current request is not a multipart request"
Any suggestion?
I don't know how your this.api.postWithoutEntity method works, but you aren't using headers variable. You must pass your headers on request
const headers = new Headers({ 'Content-Type': 'multipart/form-data' });
return this.http.post<any>(
"/socialintegration/callback/attachment",
{recipientId: this.selected.custSocId, file: formData},
headers
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.