Error when attempting to create a Video Poll


#1

I’ve been playing around in a Sandbox account and whitelisted it for the PROMOTED_MEDIA_POLLS product.

I successfully uploaded an image using the POST media/upload endpoint, added it to a poll using the media_key parameter, and created it. It returned the card_uri, I added the card_uri to a Tweet and Tweeted it.

Next, I wanted to create a video poll. I uploaded a video using the chunked endpoints. It returned the media id and I attempted to create the card. When creating only a video poll card, I get this error.

  "errors": [
    {
      "code": "INTERNAL_ERROR",
      "message": "AdsAccountFilter: ads account not found"
    }
  ],
  "request": {
    "params": {}
  }
}

Could this be a bug?

Sam


#2

Hi @SamSchmir! First of all, after uploading a video you should wait for it to get processed - this can take a few minutes. Secondly, can you please post the HTTP request you are making?

Thank you.


#3

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


#4

Hi @SamSchmir! Thank you for the very detailed information! The call using the media_id, and not the media_key, is correct. I see you’re using the sandbox environment to create the poll - according to Create Card issues, media files uploaded on /media/upload are not available in the sandbox, so it’s expected that you would get media_id not found error. Still, I would have expected that you had received the same error when using an image. But anyway, I think that’s the issue.


#5

Ah ok @majoritasdev. That’s what I originally thought of because it makes sense that media really can’t be uploaded in a sandbox environment, but when I thought about it again, you don’t actually upload media to a sandbox account. Since the Resource URL is upload.twitter.com, the media doesn’t go to a specific account unless you add it to the media library using the POST accounts/:account_id/media_library endpoint, right? I kept trying because it confused me that images would work but not videos… :man_shrugging:


#6

Well, I think it’s a bug… that it works with images :neutral_face:.

As they say:

So maybe try creating the video poll in production?.. I assume that as long as you don’t make it a real ad it won’t display to actual users, so it’s safe to do that. I’m just assuming, because I’ve never worked with polls of any kind in the Twitter Ads API.


#7

I would, but I must be whitelisted for the PROMOTED_MEDIA_POLLS feature which is still in a limited beta. That’s why I’ve been doing all this in a sandbox environment. It lets me whitelist the feature.

I’ll try to get to the bottom of this.

Anyways, thanks for the help!