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:
- Upload an image via
"/1.1/media/upload.json"
- 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.