Unable to attach media on DM

python
tweepy
api
attachment

#1

I am using tweepy and I defined a new method to attach media to DM which is as follows:

  @property
    def send_media(self):
        """ :reference: https://dev.twitter.com/rest/reference/post/direct_messages/new
            :allowed_param:'user', 'screen_name', 'user_id', 'text'
        """
        return bind_api(
            api=self,
            path='/direct_messages/events/new.json',
            method='POST',
            payload_type='media',
            allowed_param=['user', 'screen_name', 'user_id', 'text','attachement'],
            require_auth=True
        )

I am sending parameters of attachment in this way:

api.send_media(user_id =status.direct_message['sender_id'], text =response, attachment={'type':'media','media_id': mediaID})

But my bot only says the text and no image is attached.
help please


#2

Are the media uploads completing successfully? Are you using a valid media ID (string) when adding the attachment?


#3

yes I am getting a valid media ID, i have also tried replacing media ID by the value i got after uploading the pic from python shell (ā€˜877121579854856200Lā€™).


#4

The number ending in L will not be a valid ID - you should use the string representation instead.


#5

string representation of exactly what?


#6

media_id_string I think (check the docs)