Getting internal server wjile running on flutter, ApI working on postman & curl btw, Any solution to reslove this issue
Future<void> uploadFile(String audioFilePath, BuildContext context) async {
print(audioFilePath);
var dio = Dio();
var formData = FormData.fromMap({
'fileName': await MultipartFile.fromFile(
audioFilePath,
filename: 'vibe.mp3',
contentType: MediaType('audio', 'mpeg'),
),
});
try {
var response = await dio.post(
'https://vocal-remover.p.rapidapi.com/api/v2/FileUpload',
data: formData,
options: Options(
method: 'POST',
headers: {
'X-RapidAPI-Host': 'vocal-remover.p.rapidapi.com',
'X-RapidAPI-Key':
'a4b9ff9474msh1e793djsn7af3d879b8fa',
},
),
);
if (response.statusCode == 200) {
print(response.data);
} else {
print(response.statusMessage);
}
} catch (e) {
print('Error uploading file: $e');
}
}
Participez à la discussion - ajoutez un commentaire ci-dessous:
write me firdavscoder1@gmail.com
hi, I have done everything there is, looks like the api is not compatible with dart, my guess is headers are being handled case sensitively by the server (i.e. it is not in compliance with the RFC), dart force converts everything in headers to lowercase, i have checked the log and request from postman is working because headers are on original case but when using flutter it gets converted to lowercase
Also when requesting from dart request body is 100 and from postman its 99,
ps - one more person in discussion also mentioned same error, ie -internal server error 500
Is there any specific file upload requirements. this is the response body returned by server
Hi. It is not due to API error but rather you might not request data correctly. Ask any flutter experts to solve this issue.