POST statuses/update formatting uri


I’m trying to post to twitter using the API, and I already have my 4 keys from my app and account. I can post simple messages (strings containing no special characters). When I try to post the following message: Maybe he’ll finally find his keys. #peterfalk, I get a 401 saying that it couldn’t authenticate me. I’ve been comparing to twitter4J and the oauthBaseString is the same:


Here is what my Authorization header looks like:

OAuth oauth_consumer_key=[mykey],oauth_nonce=3898605892584130366,oauth_signature_method=HMAC-SHA1,oauth_timestamp=1501185867,oauth_token=[mytoken],oauth_version=1.0,oauth_signature=I6AGkpSgiF90R8jf2C6vt5RfMgw%3D

and the Uri:'ll%20finally%20find%20his%20keys.%20%23peterfalk

Any thoughts on how I can correct this problem?
My code works if I have a simple message such as “HelloWorld”


You should never be including OAuth parameters as URL parameters in the API call.


I’m a bit confused, how would I specify the status to post then?


Status is a valid parameter. Oauth tokens are not. They go in the header not in the URL.


Wait… Sorry. It’s late here and maybe I’m confused and not reading correctly. You said the baseString. Apologies! I’ll dig in more tomorrow to check I understand the issue better :slight_smile:


Ok thanks, I might not have been clear. But I am putting the OAuth … as the value for the Authorization header.


You were clear - I read too fast on my commute - my bad. Bear with me (or anyone else who can dive in to suggest what might be up in the meantime!)


I ended up getting this to work by putting my status in the body instead of the URL as a parameter. Set content type to application/x-www-form-urlencoded.