Skip to content

unexpected token when calling repos.contents.readme with "html" media type #223

@Naatan

Description

@Naatan

Calling the API like this:

github.repos.contents.readme user, repo, accept: 'application/vnd.github.v3.html'

Fails with error:

/home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/json-1.8.2/lib/json/common.rb:155:in `parse': 795: unexpected token at '<div class="announce instapaper_body md" data-path="readme.md" id="readme"><article class="markdown-body entry-content" itemprop="mainContentOfPage"><h1> (MultiJson::ParseError)

I removed the rest of the error as its just the parsed readme in HTML.

Stack trace:

    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/json-1.8.2/lib/json/common.rb:155:in `parse'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/multi_json-1.10.1/lib/multi_json/adapters/json_common.rb:16:in `load'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/multi_json-1.10.1/lib/multi_json/adapter.rb:20:in `load'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/multi_json-1.10.1/lib/multi_json.rb:119:in `load'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/jsonable.rb:12:in `decode'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/response/jsonize.rb:13:in `block in <class:Jsonize>'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/response/jsonize.rb:25:in `call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/response/jsonize.rb:25:in `parse'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/response.rb:16:in `on_complete'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/response.rb:9:in `block in call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/response.rb:57:in `on_complete'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/response.rb:8:in `call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/response.rb:8:in `call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/request/basic_auth.rb:16:in `call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/request/url_encoded.rb:15:in `call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/request/multipart.rb:14:in `call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/request/jsonize.rb:23:in `call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139:in `build_response'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/connection.rb:377:in `run_request'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/faraday-0.9.1/lib/faraday/connection.rb:140:in `get'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/request.rb:68:in `call'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/request/verbs.rb:20:in `get_request'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/client/repos/contents.rb:30:in `readme'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/api.rb:224:in `block in execute'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/api.rb:211:in `run_callbacks'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/api.rb:223:in `execute'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/github_api-0.12.3/lib/github_api/api.rb:183:in `block in method_added'
    from /home/nathan/Projects/foo/lib/foo/command.rb:120:in `block in parse_category'
    from /home/nathan/Projects/foo/lib/foo/command.rb:66:in `each'
    from /home/nathan/Projects/foo/lib/foo/command.rb:66:in `parse_category'
    from /home/nathan/Projects/foo/lib/foo/command.rb:42:in `block in resources'
    from /home/nathan/Projects/foo/lib/foo/command.rb:41:in `each'
    from /home/nathan/Projects/foo/lib/foo/command.rb:41:in `resources'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/middleman-core-3.3.10/lib/middleman-core/cli.rb:72:in `method_missing'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/command.rb:29:in `run'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/command.rb:126:in `run'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/middleman-core-3.3.10/lib/middleman-core/cli.rb:20:in `start'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/gems/middleman-core-3.3.10/bin/middleman:18:in `<top (required)>'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/bin/middleman:23:in `load'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/bin/middleman:23:in `<main>'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/bin/ruby_executable_hooks:15:in `eval'
    from /home/nathan/.rvm/gems/ruby-1.9.3-p547/bin/ruby_executable_hooks:15:in `<main>'

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