-
Notifications
You must be signed in to change notification settings - Fork 662
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
Content-Type Override #331
Comments
+1 |
Same is true about get(). Seems like these snippets are the problem (notice
One option is to be able to set the content-type to use for all requests when constructing an OAuth object. I don't love adding yet another parameter to the constructor so what about adding a I'm happy to put together a PR if people think this is the way to go. |
A minimal change (which I think is less obvious/explicit and thus don't like as well) is to change
That way if you include 'Content-Type' in the |
@fayebutler I merged a patch into oauth-libre (written by @rausanka ) that should solve this issue: https://github.com/omouse/node-oauth-libre/pull/30 it's in release 0.9.17 of oauth-libre |
+1 |
From this bit of code in _putorPost() function in oauth.js (line 496)
if ( typeof post_body != "string" && !Buffer.isBuffer(post_body) ) { post_content_type= "application/x-www-form-urlencoded" extra_params= post_body; post_body= null; }
With the new Twitter DM API I need to be able to set the Content Type to JSON when the post-body is JSON
https://dev.twitter.com/rest/reference/post/direct_messages/events/new
So currently my post function looks like this :
oauth.post(
'https://api.twitter.com//1.1/direct_messages/events/new.json',
access_token,
access_token_secret,
{"event": {"type": "message_create", "message_create": {"target": {"recipient_id": "4534871"}, "message_data": {"text": "Hello World!"}}}},
"application/json",
function(e, data ) {
}
);
But as post-content-type gets overridden to "application/x-www-form-urlencoded", I get an error.
Could this please be updated so you can specify the content type?
The text was updated successfully, but these errors were encountered: