Search code examples
c#twitterlinq-to-twitter

Sending Tweet with video (Error creating status.)


I am trying to send a tweet with video but getting following error in the "await twitterCtx.TweetWithMediaAsync" line

Error creating status.

        if (Request.Params["VideoId"] != "")
        {
            AspNetAuthorizer auth = (AspNetAuthorizer)Session["TW"];

            var twitterCtx = new TwitterContext(auth);

            string status = "Testing TweetWithMedia #Linq2Twitter £ " + DateTime.Now.ToString(CultureInfo.InvariantCulture);
            const bool PossiblySensitive = false;
            const decimal Latitude = TwitterContext.NoCoordinate;
            const decimal Longitude = TwitterContext.NoCoordinate;
            const bool DisplayCoordinates = false;
            const string PlaceID = null;
            string ReplaceThisWithYourImageLocation = @"c:\foo\foo\" + Request.Params["VideoId"] + ".mp4";

            byte[] imageBytes = File.ReadAllBytes(ReplaceThisWithYourImageLocation);

            Status tweet = await twitterCtx.TweetWithMediaAsync(
                status, PossiblySensitive, Latitude, Longitude,
                PlaceID, DisplayCoordinates, imageBytes);

        }

video size ~3MB


Solution

  • The Twitter API only supports uploading images. Also, TweetWithMediaAsync (=Twitter API statuses\update_with_media endpoint) is deprecated and replaced with UploadMediaAsync (=Twitter API media\upload endpoint).

    You can download LINQ to Twitter source code for a demo and read my blog post, Uploading Multiple Images in Parallel with Async and LINQ to Twitter, for more info.

    Update

    Please see @Jagadeesh Govindaraj answer as Video uploads are a new capability that is now available.