Expand my Community achievements bar.

'Forbidden Error 403: When Uploading file in WebApp

Avatar

Level 5

Hi team,

 

I am using v8, and trying to upload a file to ACC using  /nl/jsp/uploadFile.jsp.

When we use the v5 compatibility fileInput file gets uploaded to the server, while if I use the normal HTML and AJAX to upload the file, it gives an error. ( 403 - Forbidden )

 

If I use postman / nodejs script to read the file and upload to /nl/jsp/uploadFile.jsp, file gets uploaded properly. 

 

What could be the reason 403 error, I tried with __sessiontoken cookie, __securitytoken, and also with Bearer Token, which works in postman, but not within the WebApp

 

Please help 

 

Regards,

DG

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

6 Replies

Avatar

Community Advisor

Hello @dipendu_g Are you using correct form encoding to upload file via Ajax?

 

Here is what is used in form to upload images.

enctype="multipart/form-data"

 


     Manoj
     Find me on LinkedIn

Avatar

Level 5

Hi @_Manoj_Kumar_ , 

 

I am using FormData to store the uploaded file and then using fetch to upload. 

 

await fetch('/nl/jsp/uploadFile.jsp', {
                    method: "POST",                     
                    body: formData,
                    headers:myHeaders
            });

Avatar

Community Advisor

Hello @dipendu_g what is the value of formDate here?


     Manoj
     Find me on LinkedIn

Avatar

Level 5

Hi @_Manoj_Kumar_ 

 

let formData = new FormData();

formData.append("file",files[0])

 

Regards

Avatar

Community Advisor

Hello @dipendu_g  Do you see the same payload value in webApp with v5?

Depending on where the file is store the the payload field can change.


     Manoj
     Find me on LinkedIn

Avatar

Level 5

Hi @_Manoj_Kumar_ ,

 

I can see payload with v5, file approach. Here we are creating our own form. The v5 file upload works

 

Regards,

DG