We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

passing header with the url


For the uploader control, is there a way to send the header with the url

For example : In angular http
this.http.post(url, body, header)

7 Replies

KR Karthik Ravichandran Syncfusion Team May 9, 2018 12:11 PM UTC

Hi Manu, 

Thanks for contacting Syncfusion support.  

We have checked your query. You can achieve your requirement (“Add headers in the save and remove url’s”) by using uploading and removing events of uploader. Please refer the below code block. 

<ejs-uploader #defaultupload (uploading)="onuploading($event)" (removing)="onremove($event)" [asyncSettings]='path'></ejs-uploader> 
// To add the header in save Url 
public onuploading(args: any) {  
   args.currentRequest.setRequestHeader('Authorization', ‘username’);  
// To add header in remove Url 
public onremove(args:any) {  
  args.currentRequest.setRequestHeader('Authorization', ‘username’);  
Make sure that your custom header has been added in web.config file of your service. Please refer below code block. 

<add name="Access-Control-Allow-Headers" value="accept, maxdataserviceversion, origin, x-requested-with, dataserviceversion,content-type, Authorization" />    
Note: The feature “adding custom header in upload HTTP request” implemented and available from our 16.1.37 release.  

Please let us know if you need further assistance on this. 

Karthik R 

MM Matthew Morgan December 27, 2018 06:57 PM UTC

This doesn't work with chunked file uploading. The uploading event is only fired on the initial chunk and subsequent chunks provide no opportunity to add a header. In my case, this is fatal because I need to add a bearer token for OIDC.

PO Prince Oliver Syncfusion Team January 3, 2019 08:59 AM UTC

Hi Manu, 

Thank you for your update. 

You can also achieve same behavior for chunk upload. Recently we have introduced ‘chunkUploading’ event starting from the release version 16.4.40-beta. You can upgrade your packages through npmjs and try to pass header in the chunkUploading event arguments. Kindly refer to the following code snippet 
<ejs-uploader #chunkUpload [maxFileSize]=104857600 [autoUpload]=false (chunkUploading)="onChunkUploading($event)" (removing)="onRemove($event)" [asyncSettings]='path'></ejs-uploader>  
// To add the header in save Url on every chunk upload 
public onChunkUploading (argsany) {   
// To add header in remove Url  
public onRemove(args:any) {   
  args.currentRequest.setRequestHeader('Authorization', ‘username’); 

The chunkUploading event will trigger for uploading each chunk. Kindly refer to the following API reference: https://ej2.syncfusion.com/documentation/api/uploader/#chunkuploading  

Please let us know if you need any further assistance on this. 


EV Ervin van der Merwe August 6, 2019 08:00 AM UTC

I have the same requirement but from the angular PDF Viewer: https://www.syncfusion.com/forums/146490/how-to-pass-headers-with-pdf-viewer

AA Akshaya Arivoli Syncfusion Team August 7, 2019 05:35 AM UTC

Hi Ervin, 

We have provided the details for “How to Pass Headers With PDF Viewer” in the forum https://www.syncfusion.com/forums/146490/how-to-pass-headers-with-pdf-viewer . Please check that for further updates and revert us if any concerns. 


MP Megha Patel April 29, 2021 06:20 AM UTC

How to pass extra parameter in File Uploader Save URL?

JM Jeyanth Muthu Pratheeban Sankara Subramanian Syncfusion Team April 30, 2021 12:52 PM UTC

Hello Megha, 

Good day to you. 

We checked the reported query. We can add the extra parameter to the SaveURL using uploading event which triggers when the file is being uploaded. In that event, we can add the additional data in key-value pair with the help of customFormData property in Uploading event args. We can receive the added data in the server end by accessing the key value. 

public onFileUpload = (args: any) => { 
        // add addition data as key-value pair. 
        args.customFormData = [{ name: "Syncfusion INC" }]; 

// Get the additional data in server end by corresponding key. 
    var data = HttpContext.Current.Request.Form["name"]; 

Please find the sample and UG in the below link. 

Sample Link       : https://stackblitz.com/edit/angular-nkujjt 

Please let us know if you need any further assistance on this. 


Live Chat Icon For mobile
Up arrow icon