Read an URL from POST request

Hi, I would like create an API that receives an url to get a file, how can I access the url stored in request.POST? I don’t want to store the file or the url, just need to read the file for other porpuses.

I’m trying something like this, to test that the url is read correctly:

def eda(request):

var = request.POST[request.body.url]

response = {
    'result': 'lalala',
    'data': var,
    'code': 'success'
return Response(response)

But I get the error: 415 Unsupported Media Type

request.POST is a python dict, the way you’re trying to access the data here is wrong:

This link of the documentation it’s from a section that does not relate directly to the topic. But it shows how the request.POST should be used.

I’ve already changed the code, but keeps getting the error 415 Unsupported Media Type.
Which is the correct way to read de request values for use them directly in the view logic?

There are two different factors in play here, depending upon how you’re submitting this data to your view.

  • You’re submitting this data as HTTP POST data, in which case it’s available as a field within POST.

  • You’re submitting this as serialized JSON, in which case it needs to be deserialized from request.body.

These are two separate situations that do not overlap. The two do not mix.

What is submitting this request to the view?