update_with_media in Python


#1

I’ve got this method would work for “statuses / update”, but when trying to create it for “update_with_media” get the following error: {“errors”: [{“code”: 195, “message”: "Missing or invalid url parameter. "}]. I know the problem is in the image, but I can not think of more ways to fix it. I hope someone can help me. thanks

client = oauth.Client(consumer, access_token)
#Recogemos los datos del formulario y enviamos el tweet
tweetnew = ""
if request.method == 'POST':
       	tweetnew = request.POST['tweet']
	f=request.FILES['foto']
	encoded = base64.b64encode(f.read())
	parametros = 'status='+tweetnew+';media[]='+encoded
	twurl = "https://api.twitter.com/1.1/statuses/update_with_media.json"
	salida=client.request(
		twurl, 
		"POST", 
		body=parametros,
		headers="Content-Type:multipart/form-data",
	)