Error sending DM with media attachment using Twitter API in Java #445
Unanswered
MohanKanjula
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
I am using java and I am having the same issues with twittered |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey , I am trying to reply to a DM with a media attached . So I am using this method in the Library
PostDmResponse postDmResponse = twitterClient.createUserDmConversation("participant_id", dmMessage);I am building dmMessage object like this
String templateAttachments= "[{\"media_id\": \"%s\"}]"; String attachments = String.format(templateAttachments,mediaId); DmParameters.DmMessage dmMessage = DmParameters.DmMessage.builder().text("Testing DM with an Image ").attachments(attachments).build() ; PostDmResponse postDmResponse = twitterClient.createUserDmConversation("participant_id", dmMessage);It is giving me this errror
[main] ERROR io.github.redouane59.twitter.helpers.AbstractRequestHelper - (POST) Error calling https://api.twitter.com/2/dm_conversations/with/864922074502049793/messages {"errors":[{"parameters":{"$.attachments":["\"[{\\\"media_id\\\":\\\"1647942759276326912\\\"}]\""]},"message":"$.attachments: string found, array expected"}],"title":"Invalid Request","detail":"One or more parameters to your request was invalid.","type":"https://api.twitter.com/2/problems/invalid-request"} - 400As I checked the official twitter API documentation , there attachments is an array of json objects
{"text": "Sending a DM with media!", "attachments": [{"media_id": "1455952740635586573"}]So in which format should we send the attachment String here ? can you help me with this?
Beta Was this translation helpful? Give feedback.
All reactions