0

i am a little bit new to django rest and react , well i'am trying to update my buying form and change the state but i keep getting a bad request and getting in the response:

error:The submitted data was not a file. Check the encoding type on the form

my request:

const accept=()=> {
    const token = localStorage.getItem('token')
    var config = {
                headers: {
                    'Authorization': "Token " + token,
                    'Content-Type': 'multipart/form-data'
                 }  
            }
const data = form
data.state="semi_approved"
const formdata = new FormData()
  Object.keys(data).forEach(key => {
    console.log(key+':',form[key])
    formdata.append(key,form[key])
  })
console.log(formdata)
axios.put(`${getForm}${match.params.id}/`,formdata,config).then(res => {
  console.log(res.data)
})

}

Yasser_1D
  • 114
  • 8

1 Answers1

0

It sounds like you are trying to upload an image which would be uploaded as a base64 encoded string instead of a raw file. Multi part form data expects a full file. I think this post should help you out!

Halmon
  • 1,027
  • 7
  • 13