Media_id + website card creation errors

ads
cards

#1

Recently my requests to create website cards started failing because the media_ids don’t seem to be working properly. The steps I follow are:

  1. Upload an image via "/1.1/media/upload.json"
  2. Use the resulting media_id to create a website card via /1/accounts/{account_id}/cards/website.

Here’s a sample response from my prod logs after step 1:

{"image":{"w":800,"h":320,"image_type":"image/png"},"size":362750,"media_id_string":"922973048038481920","media_id":922973048038481920,"expires_after_secs":86400}

(I’m running in a Scala env, so there’s no diff between media_id and media_id_string.)

However when I use this media_id to create a website card, I get:

Body: {"errors":[{"code":"NOT_FOUND","message":"922973048038481920 was not found","parameter":"image_media_id"}],"request":{"params":{}}}

My code is setup to retry the 2nd request a few times with delay if it fails, but it eventually gives up.

Again, this flow was working properly until recently.

The sandbox endpoint returns an error as well, but this returns an internal error instead.

~ ❯❯❯ twurl -X POST -H upload.twitter.com "/1.1/media/upload.json" -f ~/Downloads/twitterimage.png -F media | jq
{
  "media_id": 922978431968661500,
  "media_id_string": "922978431968661504",
  "size": 362750,
  "expires_after_secs": 86400,
  "image": {
    "image_type": "image/png",
    "w": 800,
    "h": 320
  }
}
~ ❯❯❯ twurl -X POST -H ads-api-sandbox.twitter.com "/1/accounts/gq0zn9/cards/website?name=test-website-card&website_title=test-website-title&website_url=https://twitter.com/&image_media_id=922978431968661504" | jq
{
  "errors": [
    {
      "code": "INTERNAL_ERROR",
      "message": "Internal Error"
    }
  ],
  "request": {
    "params": {}
  }
}

The image in question is this one, but I get the same error with a lot of other images with the same dimension / size / format.


#2

Thanks for the information, @CMP. Are you using the additional_owners parameter when uploading the media asset? More details on additional_owners here.


#3

Thanks. I am able to successfully create a website card by specifying additional_owners when uploading the media as well as as_user_id when creating the card.

A couple of notes:

  1. The documentation for creating website cards does not specify that we need to pass as_user_id anywhere in the request; I inferred that from the link you referenced.
  2. My application, without this fix, had already created other media + cards for the same promotable user successfully in other campaigns (and for other promotable users in other campaigns as well). I’m still not sure how that’s possible since none of those calls contained additional owners or as_user_id.

#4

Thanks for confirming that it’s working, @CMP.

The additional_owners requirement is for all media, regardless of where it’s used. You’re right that we should make that clearer. We’ll start by clarifying that additional_owners is required when the media will be used by a user other than the authenticated user in the media/upload documentation.

In terms of your second note, we fixed a bug where this requirement was not being respected on card creation.

Thanks again for reaching out to us.


#5

After some more testing I see that passing as_user_id when creating website cards (my point 1 above) is not required for the request to succeed. What is required is the additional_owners param when uploading media. Thanks again @juanshishido for providing clarity.