Chunk Video upload Finalize returns 400 Bad Request error?




Am trying to upload a video which of 20 sec and it met with all requirements of twitter specifications. In finalize request am getting BadRequest error. Could any one please help me. I am using LinkToTwitter API.


  1. Init -> get media_id
  2. Append segment 0 -> get 204 status code
    3)Finalize --> Returns Bad Request.

Thanks and Regards,
Madhu Kumar.


Can you provide a link to the media so we can attempt to reproduce?

Also, what specifically is the full Json error you receive?

We have this sample code to help isolate whether it’s the media or the code:


hello, I resoleved the issue as in ducument they said convert base64 file string
_client.DefaultRequestHeaders.Add(“Authorization”, header);

                form.Add(new StringContent("APPEND"), "command");
                form.Add(new StringContent(MediaID), "media_id");
                form.Add(new StringContent(cnt.ToString()), "segment_index");

                BasicProperties pro1 = await file.GetBasicPropertiesAsync();
                //   Stream stream = await file.OpenStreamForReadAsync();
                IBuffer buffer = await FileIO.ReadBufferAsync(file);
                byte[] bytes = System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.ToArray(buffer);
                string fileString = Convert.ToBase64String(bytes);
                byte[] byteArray = Encoding.UTF8.GetBytes(fileString);
                MemoryStream stream = new MemoryStream(byteArray);
                HttpContent httpContent = new StreamContent(stream);
                //   form.Add(httpContent, "media_data");
                form.Add(httpContent, "media_data");

                var Response = await _client.PostAsync(new Uri(URL), form);


After Finalize the video, I want to make the tweet this with upload video

i used following code for make tweet with uploaded video

string url = “”;
string response = string.Empty;
string quary = “posted from stratus”;

        MultipartFormDataContent form = new MultipartFormDataContent();        
        form.Add(new StringContent(Media_id), "media_ids");
        form.Add(new StringContent(quary, Encoding.Unicode), "status");
        HttpClient _client1 = new HttpClient();
        string header = DriveUtilities.GenerateSignatureforTwitterVideo(url, "", Twitter_AccessToken, Twitter_AccessTokenSecret);

        _client1.DefaultRequestHeaders.Add("Authorization", header);
        var _Response = await _client1.PostAsync(new Uri(url), form);

its posting only status not the video while i successfully finalize the video during the upload


@Hari55490758 Tweet creation with mediaId could fail if it doesn’t pass validations. It will be easy to debug if you could post the video file. Also, we are working on improving error message returned from tweet creation api.