I have tried almost all options but not getting through. My Django server is working fine with Postman but when I try it from my React Native app, it gives an error
[Error: Request failed with status code 400]
My code is:
submitData = () => { console.log("submitQuestionDataToServer"); let form_data = new FormData(); form_data.append('qOne_img', Platform.OS === 'android' ? photoUri : photoUri.replace('file://', '')); form_data.append('qOne_img', Platform.OS === 'android' ? secondPhotoUri : secondPhotoUri.replace('file://', '')); form_data.append('question_title', qTitle); form_data.append('asked_by', "http://127.0.0.1:8000/auth/users/2/"); let url = 'http://127.0.0.1:8000/api/questions/'; axios.post(url, form_data, { headers: {"Content-Type": "multipart/form-data","Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Nk", } }) .then(res => { console.log("res *******") console.log(res.data); }) .catch(err => console.log(err)) }
Thanks in advance.