Bug - EndPoint: https://api.twitter.com/1.1/statuses/update.json with image


Hi Twitter Team :slight_smile:

We want to use the new EndPoint to publish images, but we have the following problem:

Message: The Artificial Intelligence (AI) market will exceed 100 billion dollars for 2025% 2C according to numbers calculated by Constellation Research :point_right::point_right:
ImageURL: https://files.merca20.com/uploads/2019/01/bigstock-174418255.jpg

Publish Image: https://upload.twitter.com/1.1/media/upload.json => OK. media_ids = 1094832645496864768
Publish Tweat: https://api.twitter.com/1.1/statuses/update.json => KO. The remote server returned an error: (401) Unauthorized. Authorization Required.

But if we continue using the old EndPoint:
https://api.twitter.com/1.1/statuses/update_with_media.json?status=The Artificial Intelligence (AI) market will surpass 100 billion dollars for 2025% 2C according to numbers calculated by Constellation Research :point_right::point_right:

Message: The Artificial Intelligence (AI) market will exceed 100 billion dollars for 2025% 2C according to numbers calculated by Constellation Research :point_right::point_right:
ImageURL: https://files.merca20.com/uploads/2019/01/bigstock-174418255.jpg

https://api.twitter.com/1.1/statuses/update_with_media.json? => OK. Publish
URL: https://twitter.com/MMontesinoN/status/1094833243927597056

Waiting for an answer from you, we send you a cordial greeting.




This sounds like there is an error with the calculation of the OAuth signature for the request.


Hello Andypiper :slight_smile:
Thanks for your quick response.
No. Is the same user and the same signature but trying to publish by the mentioned EndPoints.
Waiting for an answer from you, receive a warm greeting.


Is your code in Javascript? Are you using the media_id or the media_id_str when posting the status update?


Hi Andypiper :slight_smile:

I’m using a Vb .Net code. (Attached Image).
It is the same code that I am using to publish the videos and it works correctly.
I’m using media_ids

Waiting for an answer from you receives a cordial greeting.

Thank you


Pasting code as an image is not helpful as it makes it very difficult to run for us locally. Please share code as code when you can.

I still think this may be an encoding issue.


Hi :slight_smile:

I paste the code. Thank you.

Public Shared Function SetTweetVideoAndImagePUBLISH(pMediaId As String, pMessage As String) As String

        Dim socialId As String = String.Empty

            Dim consumerKey As String = twitterConsumerKey
            Dim consumerSecret As String = twitterConsumerSecret
            Dim accessToken As String = twitterToken
            Dim accessTokenSecret As String = twitterTokenSecret
            Dim URL As String = "https://api.twitter.com/1.1/statuses/update.json"
            Dim method As String = "POST"

            'Set the Tweet Header.
            Dim parameters As Dictionary(Of String, String) = New Dictionary(Of String, String)() From {{"media_ids", pMediaId}, {"status", pMessage}}

            Dim encodedParams As String = EncodeParameters(parameters)
            Dim request As WebRequest = WebRequest.Create(String.Format("{0}?{1}", URL, encodedParams))

            request = WebRequest.Create(String.Format("{0}?{1}", URL, encodedParams))
            request.Method = method
            request.ContentType = "application/x-www-form-urlencoded"
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
            request.Headers.Add("Authorization", MakeOAuthHeader(consumerKey, consumerSecret, accessToken, accessTokenSecret, method, URL, parameters))

            Using response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
                If response.StatusCode = HttpStatusCode.OK Then

                    Dim receiveStream As Stream = response.GetResponseStream()
                    Dim readStream As StreamReader = New StreamReader(receiveStream, Encoding.UTF8)
                    Dim respuesta As String = readStream.ReadToEnd()

                    Dim twitterMedia As Entities.Twitter.TwitterMediaPublishResponse = New JavaScriptSerializer().Deserialize(Of Entities.Twitter.TwitterMediaPublishResponse)(respuesta)

                    socialId = twitterMedia.Id


                End If
            End Using

        Catch ex As WebException

            Dim errorMessage As String = String.Empty
            If Not ex.InnerException Is Nothing Then
                errorMessage = ex.InnerException.ToString()
                errorMessage = ex.Message
            End If

            Dim argsTwitterResult As New TwitterResultEventArgs()
            Dim resultPublication As Entities.Twitter.ResultPublication = New Entities.Twitter.ResultPublication()
            resultPublication.Id = -1
            resultPublication.IsError = True
            resultPublication.Message = "Método: Twitter.SetTweetVideoPUBLISH: " & errorMessage
            argsTwitterResult.ResultMessageInPage = resultPublication
            argsTwitterResult.IdTimeline = -1
            RaiseEvent TwitterResult(New Object(), argsTwitterResult)

            Throw ex

        End Try

        Return socialId

    End Function


Can you share the video file.



This is the video file:

And this is the tweet:



Hi Andypiper :slight_smile:

Any ideas regarding this issue?

Thanks in advance


I’ve just uploaded and posted this video using the chunked upload endpoint and our Python sample, so I suspect there’s an issue with the auth headers.


Hi :slight_smile:

But we do not have any problem to upload the video. This process does it perfectly.
The problem we have when trying to upload the image, as we had told you when we opened the ticket.
Can you tell us something about the image?
We are receiving many complaints.

Thanks in advance


Apologies for my confusion on image and video.

I’ve just posted your image using the same code (except that I changed the code using a format of image/jpeg and category of tweet_image). I am not very familiar with - is it VB.NET that you’re using? so it is difficult for me to debug.

See this note in the Uploading Media guide

  • Because the method uses multipart POST, OAuth is handled differently. POST or query string parameters are not used when calculating an OAuth signature basestring or signature. Only the oauth_* parameters are used.

I think you may be adding these parameters, and this is leading to an OAuth error.


Hi Manuel,
We have been using this endpoint for years without issues
Since your code works with only text and videos, I think the problem might be with the media/upload.js code
Can you share that code here?