[401] the server responded with status 401


#1

https://api.twitter.com/1.1/search/tweets.json?q="10.1055/s-0035-1566433"&count=100&include_entities=1&result_type=recent

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


#2

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.


#3

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********"
Content-Type:application/json;charset=UTF-8
Origin:file://
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/30.0.0.0 Safari/537.36
Query String Parameters
status:Hello
Request Payload:
media_data: “iVBORw0KGgoAAAANSUhEUgAABIgAAAJECAYAAAB91h82AAAgAElEQVR4Xuy9C5wV1Z3vW7W7G2gEbdQY30AIMJk4Iy3OTE4SD92JMJkEXzdxziXMxG6Vl95ENJzJTCaf0EwyJ3cmKpLcaACFxkTNDWciIpkk6oRm8po5R2yMSYwQYvsC3zTS2NB07zq/f+2qpnqzu3vX3rVWrar6VbLd9N5r/dda3/Xftdb61XrYFi8SIAESIAESIAESIAESIAESIAESIAESIIFME7AzXXoWngRIgARIgARIgARIgARIgARIgARIgARIwKJARCcgARIgARIgARIgARIgARIgARIgARIggYwToECUcQdg8UmABEiABEiABEiABEiABEiABEiABEiAAhF9gARIgARIgARIgARIgARIgARIgARIgAQyToACUcYdgMUnARIgARIgARIgARIgARIgARIgARIgAQpE9AESIAESIAESIAESIAESIAESIAESIAESyDgBCkQZdwAWnwRIgARIgARIgARIgARIgARIgARIgAQoENEHSIAESIAESIAESIAESIAESIAESIAESCDjBCgQZdwBWHwSIAESIAESIAESIAESIAESIAESIAESoEBEHyABEiABEiABEiAB/T6P*********************************”


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.


#4

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?


#5

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