"Post Image data using POSTMAN"
That's not how you send file on postman. What you did is sending a string which is the path of your image, nothing more.
What you should do is;
- After setting request method to POST, click to the 'body' tab.
- Select form-data. At first line, you'll see text boxes named key and value. Write 'image' to the key. You'll see value type which is set to 'text' as default. Make it File and upload your file.
- Then select 'raw' and paste your json file. Also just next to the binary choice, You'll see 'Text' is clicked. Make it JSON.
You're ready to go.
In your Django view,
from rest_framework.views import APIView
from rest_framework.parsers import MultiPartParser
from rest_framework.decorators import parser_classes
@parser_classes((MultiPartParser, ))
class UploadFileAndJson(APIView):
def post(self, request, format=None):
thumbnail = request.FILES["file"]
info = json.loads(request.data['info'])
...
return HttpResponse()
Now you can hover the key input and select "file", which will give you a file selector in the value column: