Invalid media Id

ads
media-upload

#1

Hi,

We’re trying to upload in image for use in a Website Card but keep getting the following error when trying to check the status:

{
“request”: “/1.1/media/upload.json”,
“error”: “Invalid mediaId.”
}

The JSON returned from the original upload does return media_ids, we’ve tried passing both in:

Any ideas?


"error": "Invalid mediaId."
#2

Has this just started happening, and is it happening consistently?


#3

We’ve just started to hook this up and it’s happening every time, (only tried 3 times).
Thanks.


#4

Hi, @SocialOpinions. Please provide the series of requests that are causing this, preferably using twurl, so that we can try to reproduce this error. Thanks!


#5

Hi @juanshishido, I’m not using twurl but using a .net class to perform the rest api a calls:

https://upload.twitter.com/1.1/media/upload.json
https://ads-api.twitter.com/1/accounts/18ce549rjnj/cards/website

Are the end points my class uses and here is an extract of the request headers for the call that fails from the .net class:

_HttpRequestHeaders = {Content-Type: application/x-www-form-urlencoded
Authorization: OAuth oauth_version=“1.0”,oauth_consumer_key="",oauth_nonce=“5EFD3BC67667E1117667E1117667E111”,oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1473249764”,oauth_to…


#6

@andypiper @juanshishido
We are having the exact same issues - all media uploads are failing.
A simple example:
twurl -H upload.twitter.com “/1.1/media/upload.json” -f ~/Pictures/IMG_3877.JPG -F media -X POST
that returns a media_id of 774281214865702912
but then
twurl -H upload.twitter.com “/1.1/media/upload.json?command=STATUS&media_id=774281214865702912"
returns
{“request”:”/1.1/media/upload.json",“error”:“Invalid mediaId.”}

Please help!


#7

Does a subsequent STATUS request confirm that the upload was ok?


#9

No, it doesn’t. Every call to:
twurl -H upload.twitter.com “/1.1/media/upload.json?command=STATUS&media_id=774281214865702912”

returns the same “Invalid mediaId” error

Is there some other STATUS request I can make?

Is there an endpoint to get a list of valid mediaIds?


#11

Hi, all. Just a quick update. We’re still investigating why we’re seeing the following error when checking the status of a media processing operation:

$ twurl -H upload.twitter.com "/1.1/media/upload.json?command=STATUS&media_id=12345" | jq
{
  "request": "/1.1/media/upload.json",
  "error": "Invalid mediaId."
}

However, it is possible to use image media in creatives. It does not seem like this is the case for video, though.

We’ll update this thread once we know more. Thanks for your patience.


#13

Thanks @juanshishido - look forward to your update.


#14

@SocialOpinions You must not call STATUS command if FINALIZE response doesn’t contain ‘processing_info’ field.

“If the response contains a processing_info field, then use the STATUS command to poll for the status of the FINALIZE operation.” - https://dev.twitter.com/rest/reference/post/media/upload-finalize


#16

Hi @tushar_io - I’m not calling the STATUS command though?

Also - I am still getting them same problems in that I simply cannot upload any media.

Here is a sample of my code:

//https://ads-api.twitter.com/1/accounts/:account_id/cards/website
RequestBuilder(oAuth, “POST”, “https://ads-api.twitter.com/1/accounts/” + accountId +"/cards/website");

        rb.AddParameter("name", name);
        rb.AddParameter("website_title", websiteTitle);
        rb.AddParameter("website_url", websiteURL);
        rb.AddParameter("image_media_id", imageMediaId);

I have a valid media_id.


#17

@SocialOpinions: To clarify, you’re able to successfully upload an image using the media/upload endpoint, but get the Invalid mediaId error only when trying to associate that image with a website card?


#18

@juanshishido - Sorry it’s taken a while to get back to you on this but basically yes. I tried it out again a few days ago and still have the same issues. The first step returns the mediaId and then when I try the second step I get the error.


#19

We’re still working to identify the issue here, @SocialOpinions. We’ll update as soon as we know more. Thanks!


#20

@juanshishido - thanks, keep me posted!


#21

@SocialOpinions: We’re able to create a website card without issue. Please see the steps below.

Uploading the image. Please note that: (1) “the ratio of of image width/height for website cards must be 5:2” (source) and (2) the additional_owners parameter allows you to specify the user(s), by user_id, who are allowed to use the media (source).

$ twurl -X POST -H upload.twitter.com "/1.1/media/upload.json?additional_owners={additional_owners}" --file image.jpg --file-field "media" | jq
{
  "media_id": 790053336116453400,
  "media_id_string": "790053336116453376",
  "size": 96203,
  "expires_after_secs": 86400,
  "image": {
    "image_type": "image/jpeg",
    "w": 900,
    "h": 360
  }
}

Creating the website card.

$ twurl -X POST -H ads-api.twitter.com "/1/accounts/{account_id}/cards/website?name=test-website-card&website_title=test-website-title&website_url=https://twitter.com/&image_media_id=790053336116453376" | jq
{
  "data_type": "card",
  "data": {
    "name": "test-website-card",
    "image": {image_url},
    "preview_url": {preview_url},
    "website_cta": "READ_MORE",
    "id": "1aabc",
    "account_id": {account_id},
    "created_at": "2016-10-23T00:00:01Z",
    "website_title": "test-website-title",
    "website_url": "https://twitter.com/",
    "updated_at": "2016-10-23T00:00:01Z",
    "deleted": false,
    "card_type": "WEBSITE"
  },
  "request": {
    "params": {
      "name": "test-website-card",
      "image": {image_url},
      "account_id": {account_id},
      "website_title": "test-website-title",
      "website_url": "https://twitter.com/",
      "card_type": "WEBSITE"
    }
  }
}

If, after following these steps, there are still issues, please provide the requests you are making, using twurl.


Error uploading websitecard image statusCode Forbidden code 326
Create a promotional Tweet with Website Card
Image for website card
#22

@SocialOpinions: Were you able to associate an image with a website card?


#23

@juanshishido - I’ll be trying tonight, I believe my image size is ok but will triple check it all again in light of your most recent updates and feedback. Thanks for your support!


#24

Sounds good, @SocialOpinions. Keep us posted :slight_smile: