I am calling the image upload API (Django REST API) from my view in a separate Django project.
My View
if request.method == 'POST' and request.FILES['file']:
try:
resp = requests.post(
"http://19.******/BankImage_API",
files = {"file" :request.FILES['file']},
headers={"content-type": "multipart/form-data",
"Authorization": "Token 71117971*************"
}, verify=False)
API
class Bankimageapi(APIView):
def post(self, request):
if request.method == 'POST' and request.FILES['file']:
try:
........
When I tried to upload an image, I got an error in API where FILES
is <MultiValueDict: {}>
:
django.utils.datastructures.MultiValueDictKeyError: 'file'
Please guide me to solve this problem.