Twurl direct_message/event/new return 415 Media Unsupported

restapi
media-upload
directmessages

#1

Hello
I am trying to get the POST /1.1/direct_messages/events/new.json to work.

I am using twurl, and uploading media and then passing media id to the new.json post
The upload completes successfully
the Direct message post completes successfully if the attachment is not included

I am getting the 415 unsupported media type returned when adding the media attachment.

Note the upload returns a media_key that starts with 5_######### (same as media_id)

I am using twurl
The upload is:
twurl -H upload.twitter.com /1.1/media/upload.json?media_category=dm_image -f ~/plot.png -F media -X POST -t

and I have tried
twurl -H upload.twitter.com /1.1/media/upload.json -d media_category=dm_image -f ~/plot.png -F media -X POST -t

The direct message call is:
twurl -A 'Content-type: application/json' -X POST /1.1/direct_messages/events/new.json -d '{"event": {"type": "message_create", "message_create": {"target": {"recipient_id": "8461682593########"}, "message_data": {"text": "picture post", "attachment": {"type": "media","media": {"id": "895066<returned from upload>"}}}}}' -t


#2

OK … newbie error … problem solved

Upon careful counting of the closing braces }, I noted I was missing one. the 415 response is cryptic in this situation perhaps just a standard 400 or even 422 could help.


#3