[401] the server responded with status 401



I am having every thing that twitter needed. And also Access Token is generated again and again. but problem is still raised…Please help me…
thanx in Advance…

Sorry for my english


401 is “Unauthorized” - Check if you can make the call using the API console: Under “OAuth Signature generator” https://dev.twitter.com/rest/reference/get/search/tweets - try the call with curl first just to check.

One common issue is with your clock - if your PC or server time is more than a few minutes wrong, OAuth has problems.

Do you mean you are creating new access tokens again and again? Access tokens can be saved for later - you don’t need to regenerate them that often.


Hi, i’m trying to call the REST API to post a tweet with a photo (base64 format).
I tried to post also without the Query String Parameter but I did not succeed.

Request URL:https://upload.twitter.com/1.1/media/upload.json?status=Hello
Request Method:POST
Status Code:401 Authorization Required
Request Headersview source
Accept:application/json, text/plain, /
Authorization:OAuth oauth_consumer_key=“TGOFLgj6iTj9**********”,oauth_nonce=“Sem60****”,oauth_signature_method=“HMAC-SHA1”,oauth_token=“1913*************”,oauth_timestamp=“1501057973”,oauth_version=“1.0”,oauth_signature="53e%2BDY9RiUiehxmEz********"
User-Agent:Mozilla/5.0 (Linux; Android 4.4.2; LG-V500 Build/KOT49I.V50020f) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/ Safari/537.36
Query String Parameters
Request Payload:

The Base64 image is more larger than the one i have posted.
It could be a limit of size on media?!

I would be grateful if somebody could help me.
Thank you.


This question is not related to the original thread so you would have been better off starting a new one under the Media APIs category.

There is no status parameter on the media/upload endpoint. Posting a Tweet with media is a two step process where you need to upload the image and then post a Tweet attaching the media ID.

How large is the file? What error are you seeing?


Thank you for the reply.
I will open a new topic under that category.