Ir al contenido principal

Entradas

Mostrando entradas de septiembre, 2019

Django REST framework ¿cómo mandar datos a un endpoint?

import requests import json url = "http://ruta/de/mi/endpoint/" headers = {     "Authorization" : "Token 157a4a8dd0e1e8b9078c5494e35ef49e9fcb7dd7",} } payload = {     "distrito" : 1,      "seccion" : 1,      "pan" : 1,      "pri" : 1,      "prd" : 1,      "morena" : 1 } files_info = {      'foto': ('index.jpg', open('index.jpg', 'rb'), 'image/jpg') } response = requests.post(url, headers=headers, files= files_info , data=payload) print response.text Saludos,