0

I'm having trouble while reading data from POST request.

Request screenshot

It seems everything is fine from frontend but when I'm getting nothing when trying to read the request data on the backend.

request.FILES
<MultiValueDict: {}>

request.POST
<QueryDict: {}>

request.body
*** RawPostDataException: You cannot access body after reading from request's data stream

Backend view code

def upload_file(request):   
  upload_response = requests.post(requestbuilder.create_request('/files'), files={request.FILES['file']._name:request.FILES['file']}, headers=requestbuilder.MULTIPART_HEADERS)
  return HttpResponse(upload_response.json().get('fileUrl'))

Options for ajax call

var options = {
    url: "/apps/upload/",
    method: 'post',
    addRemoveLinks: true,
    clickable: false,
    maxFiles: config.maxFiles,
    minWidth: config.minWidth,
    minHeight: config.minHeight,
    headers: {
        'X-CSRFToken': $("input[name=csrfmiddlewaretoken]").val()
    },
   }

I'm completely blank, any help would be appreciated.

0 Answers0