Statuses/update_with_media & Accented Character Issue



I realise the status/update_with_media endpoint is now deprecated, but I have an interesting issue with it I would like to understand. I have some code (written by someone else) that correctly calls the endpoint, with a correct oauth header etc and works fine (with one exception). I can supply text and an image, and a tweet is created with both. Most of that same code is also used to call statuses/update method, and this also works.

Here is the weird thing; when the text for the tweet status contains an accented char, the call for update_with_media fails with a 401 unauthorised response, and an error from Twitter saying I couldn’t be authenticated. The same code that calculates the auth signature etc. is also used by the statuses/update endpoint and that works fine with accented characters. I thought it was probably an issue encoding the accented character in the oauth base string, but the same code is used to generate the auth header and from what I can tell the character is encoded the same way for both calls.

Using the upload media endpoint followed by the statuses/update endpoint with a list of uploaded media id’s also works fine, even with an accented character. It is only calling the older endpoint with both an image and accented character that causes the issue.

So basically I can tweet with accented characters, or images, but not both in the same status. Does anyone have any idea what might cause this?



As the calculation of the OAuth signature differs a bit for the status/update_with_media endpoint, it still could be a bug with your code, and I suspect it is. But without seeing any code, this is really hard to say :wink:



Thanks for the response, I appreciate it. I realise it probably is a bug in the code, and as the code base is fairly large and complicated by using the T4 templating engine I wasn’t really expecting anyone to do a code review (hard to post just snippets too). The original code is at and my fork is at if anyone does feel like having a look. Both suffer from the same problem. Note, this is (mostly) not my code, I’m merely trying to maintain it after the fact.

I am aware of some differences in the oauth signature for multi-part data posts. I have read in the Twitter forums and the dev API help that the signature should not include the non-oauth parameters for this type of request. I didn’t mention this in my original post as I didn’t want to confuse the issue, but here again I seem to be experiencing strange behaviour. Specifically the code is doing the wrong thing according to the online advice - it IS including the non-oauth arguments from the query string. However, when I tried generating a signature for a request to this endpoint without including those the requests all failed. With the code as it is, it works fine so long as there is no accented character yet other people seem to have found including those arguments causes a problem… both cases seem to be at odds with what I’ve read online?

In neither case do I include the body hash parameter, as the online advice states that isn’t part of the official oauth spec and isn’t used by Twitter. Is there anything else I’m missing? Have I misunderstood what I’ve read?

Thanks again.