sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.58k stars 1.3k forks source link

direct_messages/events/new => Could not authenticate you #949

Closed rdlh closed 1 year ago

rdlh commented 5 years ago

Gem version: 6.2.0

I'm trying to send DMs to a user via the gem. When I try to send it, here's what's happening:

Twitter::REST::Request.new(@client, :json_post, "/1.1/direct_messages/events/new.json", payload).perform

NoMethodError: undefined method 'json_post' for #<HTTP::Client:0x007f80cda4b898>

Twitter::REST::Request.new(@client, :post, "/1.1/direct_messages/events/new.json", payload).perform

{"errors":[{"message":"Could not authenticate you","code":32}]}

Every API endpoint is working like a charm, but this one is not. Tried to send the request with twurl, the request is working.

FabienChaynes commented 5 years ago

Hi,

As you can see here the :json_post request method was not yet supported on 6.2.0 but it is on master, and it's needed for DMs (looks like it was added with b45d545c7ebfd28e4d908037dd3fde04e3c307cf).

You can target a recent commit in your Gemfile instead of using the 6.2.0 to make it work before a new version is released.