John Viver
Posts: 0
Joined: Mon Sep 22, 2014 1:32 pm

Bad Request Error

I have Error event Run JavaScript alert("Error is: " + errorThrown); on uploadService component.
And I'm getting Error is: Bad Request
Followed every step in the tutorial... please help!

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Bad Request Error

Hello John,

Could you please give us a link to the tutorial, also please detail when do you get this in console (after what actions)?

John Viver
Posts: 0
Joined: Mon Sep 22, 2014 1:32 pm

Bad Request Error

http://devcenter.appery.io/tutorials/...
this tutorial.
I pass all steps, everything works, but the last step - testing file upload fails.
I log in successfully, then select 1 or more files and press upload button.
It returns a popup saying Error is: Bad Request

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Bad Request Error

Hi John,

Unfortunatly that's a bug. We working on it.

But here is a quick workauround for you:

1 Create JS asset:.

2 Populate it with following code:

pre

function uploadMultipleFilesHelperNew(datasource, fileList) {
var isCorrectService = false;
if (datasource) {
if (datasource.service && datasource.service.requestOptions) {
var options = datasource.service.requestOptions;
isCorrectService = options.type === 'post' && options.contentType === false && /^.*\/files$/i.test(options.url);
}
}
if (isCorrectService) {
if (fileList) {
var data = new FormData();
for (var i = 0; i < fileList&#46;length; i++) {
appendItem(data, fileList);
}
try {
datasource&#46;execute({
'allowDataModification': false,
'processData': false,
'body': {data: data},
'cache': false
});
} catch (exception) {
console&#46;log(exception&#46;name + ' ' + exception&#46;message);
hideSpinner();
}
}
} else {
console&#46;warn('This data source not be supported in the method of upload multiple files');
}

Code: Select all

 function appendItem(formData, item) { 
     if (item) { 
         if (item&#46;type === 'file') { 
             item = item&#46;files; 
         } 
         if (item instanceof FileList) { 
             for (var i = 0; i < item&#46;length; i++) { 
                 appendItem(formData, item[i]); 
             } 
             return; 
         } 
         var name; 
         if (item&#46;name) { 
             name = item&#46;name; 
         } 
         formData&#46;append(name, item); 
     } 
 } 

}

/pre

  1. Ok, now you can use "uploadMultipleFilesHelperNew" instead of "uploadMultipleFilesHelper".

    so you can invoke upload with following code:

    pre

    uploadMultipleFilesHelperNew(uploadService, Apperyio('file_input'));

    /pre

    Regards.

John Viver
Posts: 0
Joined: Mon Sep 22, 2014 1:32 pm

Bad Request Error

Thank you! could you please tell me where exactly should I place this file (and should I name in uploadMultipleFilesHelperNew ?) thanks!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Bad Request Error

Hello!

You would need to Create New--JS asset, you can give it any name.

rai
Posts: 0
Joined: Sat Oct 25, 2014 11:46 am

Bad Request Error

Hi John,

i have added and tested ...it works ,

  1. create new -- javescript

  2. enter name : any name

  3. open upload page -- design builder select upload button.

  4. edit the JS script to :
    uploadMultipleFilesHelperNew(uploadService, Apperyio('file_input'));

  5. save it and test

Yang Mega
Posts: 0
Joined: Sun Aug 31, 2014 6:08 am

Bad Request Error

I test ok on builder TEST, But run on mobile Device with export apk, the file selected button doesn't work out after click

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Bad Request Error

Hi Yang,

Please user WEINRE debugger may be there some errors: http://devcenter.appery.io/documentat...

Also please try to use "virtual click" event instead of "click".

Regards.

Return to “Issues”