Media/upload POST Base 64



I’m using C# .NET to try and POST an image to the media/upload.json end-point.

I’m not sure why, but I’m getting a 401. Here is the basic flow of my PerformRequest method.

  1. Build baseString (including parameter “media” and base64 encoded image)
  2. Sign / hash the request
  3. Build the HttpWebRequest header (method=POST, ContentType=application/x-www-form-urlencoded)
  4. Write the bytes of “media=” and the base64 string of the image data to the HttpWebRequest request stream
  5. Get the response and carry on.

I use the exact same function for posting a status update, including replying to tweets and it works fine.

Are the parameters I’m using wrong? Am I not meant to include the “media” parameter as part of the signature for media posts? Am I meant to URI Encode the base64 string for the image data?

I am posting on here because I can’t find much else that doesn’t use a 3rd party library.

How recently did Twitter deprecate the update_with_media end-point?

Many thanks for any assistance or guidance.



I have looked at Uploading Base64 Encoded Image using /1.1/media/upload.json which seems to answer some of my questions but I still get the 401.


Hi Ross - not sure about the specific issue that you’re asking about yet, but for information on deprecation - the update_with_media endpoint still works today, but will go away in the future. The new upload endpoint was added this year as part of our move to support animated GIFs, multi-photo uploads, and (in the future) potentially support for other media formats. You’re welcome to use update_with_media for now, but that’s not the best long-term approach if you’re building a new app or integration today.

HELP! update_with_media, content length, HTTP 400, 403

Thanks Andy.

As you say, long-term, I’d like to build it so that I won’t need to go back and change it.

For now, would you be able to tell me if I am using the right parameter names for this request?

Should I be using the image data as part of the baseString in the request signature?


Hi @andypiper,

Any thoughts as to what the issue could be?



Sorry, I’m at an event at the moment and don’t have a lot of time to dig into this - hopefully someone else can take a look!