Hello everyone,
We are experiencing an issue with the media_id and media_id_string returned by the https://upload.twitter.com/1.1/media/upload.json endpoint.
We are sending a request containing the parameter media_data with a base64 encoded value, and we got an invalid id right after.
Please see the example call below (I reduced the base64 but it’s a valid image that fits with Twitter requirements).
Input:
{
"url": "https:\/\/upload.twitter.com\/1.1\/media\/upload.json",
"method": "POST",
"parameters": {
"media_data": "\/9j\/4AAQSkZJRgABAQAAAQABAAD\/4QENRXhpZgAATU0AKgAAAAg[...]"
}
}
Output:
{
"media_id": 845257652766720004,
"media_id_string": "845257652766720004",
"size": 72716,
"expires_after_secs": 86400,
"image": {
"image_type": "image\/jpeg",
"w": 600,
"h": 338
}
}
Then, we try to use the uploaded image to create a tweet and it’s not working.
Input:
{
"url": "https:\/\/ads-api.twitter.com\/1\/accounts\/18ce54h5wcy\/tweet\/",
"method": "POST",
"parameters": {
"status": "Test do not use",
"as_user_id": "798425578177171456",
"media_ids": 845257652766720004
}
}
Output:
{
"errors": [
{
"code": "INVALID_MEDIA",
"message": "Invalid media ids"
}
],
"request": {
"params": {
"status": "Test do not use",
"media_ids": [
845257652766720004
],
"as_user_id": 798425578177171456,
"account_id": "18ce54h5wcy"
}
}
}
Can you please help us to understand why it’s happening?
Best,
Christopher Chauve.