In my application we set content-type = application/json
in interceptor.
But to upload a file content-type should be multipart/form-data
,i.e it will take contant-type = multipart/form-data
when we try to upload form data.
my question is how can I remove the content type set in interceptor while doing a post request to upload a file.
thanks, Harshavardhan
To Remove Existing header
if (!req.headers.has('Content-Type')) {
req = req.clone({ headers: req.headers.delete('Content-Type','application/json') });
Adding new Headers
req = req.clone({ headers: req.headers.set('Content-Type', 'multipart/form-data')})
To check the current value of the header.
req.headers.get('Accept')