Hi @majoritasdev! I’m using Twurl for this.
Firstly, here’s the request to upload an image.
twurl -H upload.twitter.com -X POST "/1.1/media/upload.json" --file "/Users/sam/Desktop/Twitter.jpg" --file-field "media"
Response
{
"media_id": 991657400909385700,
"media_id_string": "991657400909385728",
"size": 22783,
"expires_after_secs": 86400,
"image": {
"image_type": "image/png",
"w": 1024,
"h": 576
}
}
Using the given media_id to add that image to a poll…
twurl -X POST -H ads-api-sandbox.twitter.com "/3/accounts/gq1dz8/cards/poll?media_key=991657400909385728&duration_in_minutes=10080&name=Media Forward Poll&first_choice=Choice 1&second_choice=Choice 2&third_choice=Choice 3&fourth_choice=Choice 4"
Response
{
"request": {
"params": {
"name": "Media Forward Poll",
"first_choice": "Choice 1",
"third_choice": "Choice 3",
"fourth_choice": "Choice 4",
"second_choice": "Choice 2",
"media_key": "991657400909385728",
"duration_in_minutes": 10080
}
},
"data": {
"name": "Media Forward Poll",
"start_time": "2018-05-02T12:37:31Z",
"first_choice": "Choice 1",
"third_choice": "Choice 3",
"image_display_height": "576",
"image": "https://pbs.twimg.com/ad_img/991657400909385728/SJKOYwoM?format=jpg&name=orig",
"fourth_choice": "Choice 4",
"second_choice": "Choice 2",
"end_time": "2018-05-09T12:37:31Z",
"preview_url": null,
"id": "2fz4",
"account_id": "gq1dz8",
"created_at": "2018-05-02T12:37:31Z",
"duration_in_minutes": "10080",
"image_display_width": "1024",
"card_uri": "card://991657938249895937",
"updated_at": "2018-05-02T12:37:31Z",
"deleted": false,
"card_type": "IMAGE_POLLS"
}
}
Now trying for a video…
INIT Request
twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=INIT&media_type=video/mp4&total_bytes=2657405&media_category=TWEET_VIDEO"
INIT Response
{
"media_id": 991717205275537400,
"media_id_string": "991717205275537408",
"expires_after_secs": 86400,
"media_key": "7_991717205275537408"
}
APPEND Request
twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=APPEND&media_id=991717205275537408&segment_index=0" --file /Users/sam/Desktop/Video.mp4 --file-field "media"
APPEND Response
No content body
FINALIZE Request
twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=FINALIZE&media_id=991717205275537408"
FINALIZE Response
{
"media_id": 991717205275537400,
"media_id_string": "991717205275537408",
"media_key": "7_991717205275537408",
"size": 2657405,
"expires_after_secs": 86400,
"processing_info": {
"state": "pending",
"check_after_secs": 1
}
}
Checking the status of that media…
Request
twurl -X GET -H upload.twitter.com "/1.1/media/upload.json?command=STATUS&media_id=991717205275537408"
Response
{
"media_id": 991717205275537400,
"media_id_string": "991717205275537408",
"media_key": "7_991717205275537408",
"size": 2657405,
"expires_after_secs": 86384,
"video": {
"video_type": "video/mp4"
},
"processing_info": {
"state": "succeeded",
"progress_percent": 100
}
}
Attempting to create video poll.
Request
twurl -X POST -H ads-api-sandbox.twitter.com "/3/accounts/gq1dz8/cards/poll?media_key=991717205275537408&duration_in_minutes=10080&name=Media Forward Poll&first_choice=Choice 1&second_choice=Choice 2&third_choice=Choice 3&fourth_choice=Choice 4"
Response
{
"errors": [
{
"code": "NOT_FOUND",
"message": "991717205275537408 was not found",
"parameter": "media_id"
}
],
"request": {
"params": {}
}
}
Alternatively, I tried using the media-key instead of the media_id…
Request
twurl -X POST -H ads-api-sandbox.twitter.com "/3/accounts/gq1dz8/cards/poll?media_key=7_991717205275537408&duration_in_minutes=10080&name=Media Forward Poll&first_choice=Choice 1&second_choice=Choice 2&third_choice=Choice 3&fourth_choice=Choice 4"
Response
{
"errors": [
{
"code": "INTERNAL_ERROR",
"message": "AdsAccountFilter: ads account not found"
}
],
"request": {
"params": {}
}
}
That’s literally everything so hopefully the issue will be able to be narrowed down.
Sam