Invalid authorization name/value {x-li-auth-token}/{NAME_SEARCH:tdLy}

230 views Asked by At

Im working on LinkedIn invitation API but I can't send the invitation to user, using people id from search result

Seached people result

**
"{\"people\":{\"total\":2,\"all\":[{\"api_standard_profile_request\":{\"headers\":{\"total\":1,\"all\":[{\"name\":\"x-li-auth-token\",\"value\":\"NAME_SEARCH:tdLy\"}]},\"url\":\"http://api.linkedin.com/v1/people/tp2Z82Xa_I\"},\"first_name\":\"Dev\",\"id\":\"tp2Z8sad2Xa_I\",\"last_name\":\"ruby\"},{\"api_standard_profile_request\":{\"headers\":{\"total\":1,\"all\":[{\"name\":\"x-li-auth-token\",\"value\":\"NAME_SEARCH:ZbY6\"}]},\"url\":\"http://api.linkedin.com/v1/people/TyaEtFbxzL\"},\"first_name\":\"dev\",\"id\":\"TyaEtFbsdsaxzL\",\"last_name\":\"ruby\"}]}}"** 

And the invite methods following this

def send_invitation(options)
  path = "/people/~/mailbox"
  message = {
      "recipients" => {
          "values" => [
              {
                  "person" => {
                      "_path" => "/people/id=#{options[:email]}",
                      "first-name" => options[:first_name],
                      "last-name" => options[:last_name]
                  }
              }]
      },
      "subject" => "Invitation to connect.",
      "body" => options[:body],
      "item-content" => {
          "invitation-request" => {
              "connect-type" => "friend",
              "authorization" => {"name" => "x-li-auth-token","value" => "NAME_SEARCH:tdLy"}
          }
      }
  }
  post(path, MultiJson.dump(message), "Content-Type" => "application/json")
end

So I am getting this error when I call client.send_invitation(options):

LinkedIn::Errors::GeneralError: (400): Invalid authorization name/value {x-li-auth-token}/{NAME_SEARCH:tdLy}
1

There are 1 answers

0
Joshva R On BEST ANSWER

Working Fine

The name should be NAME_SEARCH and the value should be tdLy instead of what i have asked above. i have to split the value out of the oauth headers.

"authorization" => {:"name" => 'NAME_SEARCH',:"value" => 'tdLy'}