"Request for unsupported media category TweetImage with mediaId" when sending DM


#1

What media types am I able to send over DM?

The chunked API upload seems to be busted right now (https://developer.twitter.com/en/docs/direct-messages/message-attachments/guides/attaching-media)
so I tried tweeting out images manually through Twitter.com and capturing the media ID that way.

For both gifs and a static JPEG image I got

There was an error sending your message: Request for unsupported media category TweetImage with mediaId

or

There was an error sending your message: Request for unsupported media category TweetGif with mediaId

I obviously have the payload structure right (otherwise I’d get those very helpful errors messages that tell you what field is missing).
Do DMs support full media at the moment? Is it something you have to be whitelisted to use?

Thanks for the continued help.


#2

I’m not able to reproduce the “busted” behaviour at the moment. Have you tried using or modifying our large media upload Python sample? That’s my usual debugging approach. If you have example files to share then others may be able to validate what you’re seeing.

The new Direct Message endpoints are generally available (and have been since December) and there should be no additional requirements here. You should use DmImage etc for Direct Messages as documented here.


#3

Got some more information:

I’m uploading media using this script: https://github.com/desmondmorris/node-twitter/tree/master/examples#chunked-media

I get a response back from the finalze request that looks like this

{ media_id: 984834047074385900,
media_id_string: ‘984834047074385920’,
media_key: ‘17_984834047074385920’,
size: 1525405,
expires_after_secs: 86400,
processing_info: { state: ‘pending’, check_after_secs: 1 } }

This nice guy ("Bad Media, unable to process: None." when sending an uploaded video longer than 4 seconds through DM) posted about the STATUS not being taken care of but the link is dead now. I assume it was changed in the December release.

I’m sending this along with the INIT command

  command: "INIT",
  total_bytes: mediaSize,
  media_type: mediaType,
  media_category: "dm_gif"

And I’m getting the same error as the man above.

{ code: 151,
2018-04-13T16:43:15.357023+00:00 app[web.1]: message: ‘There was an error sending your message: Bad Media, unable to process: None.’ }

Thoughts?


#4

Found the documentation for STATUS.

I’m getting this back from the STATUS command

{ media_id: 984837731976015900,
media_id_string: ‘984837731976015872’,
media_key: ‘17_984837731976015872’,
size: 1525405,
expires_after_secs: 85665,
processing_info: { state: ‘succeeded’, progress_percent: 100 } }

But I’m still getting

‘There was an error sending your message: Bad Media, unable to process: None.’
when trying to send it in a DM


#5

Any ideas?

Client really wants us to send images for DM as soon as we can. <3


#7

Doh, learning to read more carefully… :blush:

Are you able to share any standalone script + image - keys example that demonstrates this? You’re definitely using media_id_string right?


#8

Well look at that. It’s working now!

I think it’s very possible I was using the wrong media id. Made that same mistake again! xD

Thanks so much Andy. I was even able to set shared=true and reuse the media id.

We’re using this images in a bot – is there anyway to avoid having to script a once daily “reupload all images and save the media IDs” part of our project? All of these images are expiring after a day.


#9

No, so far as I know the media ID does expire after 24 hours