Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

417
Visualizações
WSGIRequest object has no attribute PUT

I'm trying to make a put request to the local server using the put request using curl:

curl -X PUT -H "Content-Type: application/json" -d '{"connid":"12"}' "127.0.0.1:8000/api/kill"

I receive the same response:

'WSGIRequest' object has no attribute 'PUT'

for the following code:

def kill(req):
  conid = req.PUT['connid']
  statusres = {}

  if conid in state:
    error[conid] = 'true'
    statusres['status'] = 'ok'

  else:
    statusres['status'] = 'invalid connection Id : '+ conid
  return JsonResponse(statusres)

I also used @csrf_exempt before the function.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You have misunderstood several things here.

When you send form-encoded data, whether it's POST or PUT, in Django you always find the parameters in request.POST. So you would find your data in request.POST['conid'].

However, you are not sending form-encoded data; you are sending JSON. You need to access the request body, and pass it to the json.loads function to decode:

def kill(request):
  data = json.loads(request.body)
  conid = data['connid']
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda