Unable to attach media to direct messages



I am trying to attach image to direct messages. Documentation link: https://dev.twitter.com/rest/direct-messages/attaching-media

As described in documentation, I am using media upload REST API to upload the image. Ref: https://dev.twitter.com/rest/reference/post/media/upload-init
After getting mediaID, I am using this REST API (https://dev.twitter.com/rest/reference/post/direct_messages/events/new) to send direct message with media attachment.

However I am getting this error message:

  "errors": [
      "code": 151,
      "message": "There was an error sending your message: Bad Media, unable to process: None."

The upload REST API worked fine for the image. Can someone please point me towards the right direction.


I got a similar issue. Are you using the multi-part upload process? You may be missing the forth step. I wrote about my solution here: