New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Twitter oauth POST fails when content-type includes '; charset=UTF-8' #1313
Comments
Why not use the {
"uri": "https://api.twitter.com/1.1/statuses/update.json",
"method": "POST",
"json": true,
"form": {status:'Test status'},
"oauth": {
"token": "token",
"token_secret": "tokensecret",
"consumer_key": "consumerkey",
"consumer_secret": "consumersecret"
}
} I'm not sure that this is the exact problem, but you can try this set of options as well. |
@dbellavista , also note that specifically for Twitter you need to escape special characters by yourself, I plan to fix that, but in the meantime you can use the code from this #1287 (comment) |
Yes @simov I already do the proper escaping and I wasn't using The issue is the following and it has nothing to do with // Works on request 2.49, but not in >= 2.50
reqOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
reqOptions.body = qs.stringify({
status: 'Test status'
});
// Works on both version:
reqOptions.form = {status: 'Test status'}; Should it be considered valid or should I always use the |
Can you give us the whole options object in all cases (not only the parts you think are related)? I'm asking this because I assume that there are more options in |
Not working with {
"uri": "https://api.twitter.com/1.1/statuses/update.json",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"json": true,
"body": "status=Test%20status",
"oauth": {
"token": "token",
"token_secret": "token_secret",
"consumer_key": "consumer_key",
"consumer_secret": "consumer_secret"
}
} Not working with {
"uri": "https://api.twitter.com/1.1/statuses/update.json",
"method": "POST",
"headers": {},
"json": true,
"form": {
"status": "Test status"
},
"oauth": {
"token": "token",
"token_secret": "token_secret",
"consumer_key": "consumer_key",
"consumer_secret": "consumer_secret"
}
} |
Oh wait, in your previous comment I saw
Can you make the same tests with |
Thanks! Finally I'm able to reproduce the original issue! Not working with {
"uri": "https://api.twitter.com/1.1/statuses/update.json",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
"json": true,
"body": "status=Test%20status",
"oauth": {
"token": "token",
"token_secret": "token_secret",
"consumer_key": "consumer",
"consumer_secret": "consumer_secret"
}
} Works with both {
"uri": "https://api.twitter.com/1.1/statuses/update.json",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"json": true,
"body": "status=Test%20status",
"oauth": {
"token": "token",
"token_secret": "token_secret",
"consumer_key": "consumer",
"consumer_secret": "consumer_secret"
}
} Works with both {
"uri": "https://api.twitter.com/1.1/statuses/update.json",
"method": "POST",
"headers": {},
"json": true,
"form": {
"status": "Test status"
},
"oauth": {
"token": "token",
"token_secret": "token_secret",
"consumer_key": "consumer",
"consumer_secret": "consumer_secret"
}
} |
@dbellavista thanks for the thorough bug report it's fixed here #1314 |
Request Issue: request/request#1313
Present since request
2.50
. I have created a minimal working example: https://gist.github.com/dbellavista/a7b911f87b56bb9c47fcThe following request option
produce the following response from twitter:
Removing
; charset=UTF-8
solves the problem. However, request2.49
seems unaffected.The text was updated successfully, but these errors were encountered: