emorikawa / linkedin-oauth2

Ruby wrapper for the LinkedIn OAuth2 API
Other
70 stars 86 forks source link

`send_message` returns 400 error always. #22

Open nicooga opened 9 years ago

nicooga commented 9 years ago

Just in case, yes I have configured the gem with my app_id, app_secret, and I'm getting user tokens through the oauth2 login process using omniauth. Other endpoints, like #connections are working fine and returning data, but not #send_message.

client = LinkedIn::API.new User.find(8).linkedin_oauth2_token
client.connections
=> [stuff, stuff, ...]
user_id = client.connections.all.find { |c| c.last_name == 'Pitt' }.id
client.send_message 'test', 'asdf', [user_id]
=> Faraday::ClientError: the server responded with status 400
from /home/nicolas/.rvm/gems/ruby-2.1.1/gems/faraday-0.9.0/lib/faraday/response/raise_error.rb:13:in `on_complete'

Is possible #send_message is outdated? Can I put Faraday on verbose mode so I can debug this?

dgp commented 9 years ago

Me too got same bug. any update?

codeboxanvo commented 9 years ago

The same to mine, others work well but #send_message

dgp commented 9 years ago

@codeboxanvo I used linkedin rest API it works for me. There is problem in this gem for sending message. Here is my code Used HTTParty Gem to send message

data = {subject: 'subject', body: 'body', recipients: {values: [uid].map{|profile_path| {person: {_path: "/people/#{profile_path}"}} } }}

HTTParty.post("https://api.linkedin.com/v1/people/~/mailbox", headers: { 'Content-Type' => 'application/json'}, query: {oauth2_access_token: 'xxxxxxxxxxxxxxx'}, body: data.to_json)

codeboxanvo commented 9 years ago

From latest code, it seems the same data format with linkedin documents https://github.com/emorikawa/linkedin-oauth2/blob/master/lib/linked_in/communications.rb https://developer.linkedin.com/documents/messaging-between-connections-api

dgp commented 9 years ago

@codeboxanvo yes same format but some data is missing in request. tats y it return 400. You can look the error status.
https://developer.linkedin.com/documents/error-codes