Attaching media to direct messages not working

restapi
directmessages

#1

I am trying to upload media in direct messages.By referring this documentation https://dev.twitter.com/rest/direct-messages/attaching-media, I generated mediaId by setting media_category as dm_image and I constructed header using this https://api.twitter.com/1.1/direct_messages/events/new.json endpoint.

And then I triggered POST request with end point - https://api.twitter.com/1.1/direct_messages/events/new.json

 Content-Type - application/json
 content - {"event": {"type": "message_create","message_create": {"target": {"recipient_id": "4211191093"},"message_data": {"text": "Hello World!","attachment": {"type": "media","media": {"id": "859337626066833414"}}}}}}

and Content-Length

But I am getting 215 error message

  {"errors":[{"code":215,"message":"Bad Authentication data."}]}

I can’t able to find out what is missing in this request.Can anyone plz help me in this.

Thanks!


#2

Is it definitely oAuth signed as I found that my iOS libraries simply didn’t like signing non multi-part form data until I rewrote it to accept JSON instead

Ensure the body isn’t included with the signing request but the Content-type header is


#3

Constructed authorization header with Content-Type as application/json.Header does not contain object.Still same error persist.