Skip to content

Content-Type Override  #331

Open
Open
@fayebutler

Description

@fayebutler

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions