pengwynn/linkedin — Issue #80: MultiJson::DecodeError on 401 response
Author: mdub
Created: 2011-11-04 11:22:16+00:00
State: open

Occasionally, my app seems to be receiving unexpected 401 error responses from the LinkedIn API, confusing the error-handling in the linked in gem. More specifically, the API appears to be returning an HTML payload, but the gem expects JSON.

MultiJson::DecodeError: 743: unexpected token at '

Apache Tomcat/6.0.32 - Error report

HTTP Status 401 -

type Status report

message

description

This request requires HTTP authentication ().

Apache Tomcat/6.0.32

'

Here's the corresponding backtrace:

.bundle/gems/ruby/1.9.1/gems/json-1.6.0/lib/json/common.rb:148:in `parse'
.bundle/gems/ruby/1.9.1/gems/json-1.6.0/lib/json/common.rb:148:in `parse'
.bundle/gems/ruby/1.9.1/gems/multi_json-1.0.3/lib/multi_json/engines/json_gem.rb:13:in `decode'
.bundle/gems/ruby/1.9.1/gems/multi_json-1.0.3/lib/multi_json.rb:65:in `decode'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/mash.rb:9:in `from_json'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/helpers/request.rb:45:in `raise_errors'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/helpers/request.rb:16:in `get'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/api/query_methods.rb:32:in `simple_query'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/api/query_methods.rb:8:in `profile'
[PROJECT_ROOT]models/linked_in_profile.rb:14:in `find'

I think the gem needs to be more resilient in the face of this type of error.