Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

When I try requesting the tag c# via Serel, I get an error.

This is the error I am getting:

INFO][2013-02-25 02:06:42] Making request to /2.0/tags/c#/info?site=stackoverflow&key=mykey
JSON::ParserError: 757: unexpected token at '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>
'
    from /.rvm/gems/ruby-1.9.3-p194@myapp/gems/json-1.7.7/lib/json/common.rb:155:in `parse'
    from /.rvm/gems/ruby-1.9.3-p194@myapp/gems/json-1.7.7/lib/json/common.rb:155:in `parse'
    from /.rvm/gems/ruby-1.9.3-p194@myapp/gems/serel-1.0.1/lib/serel/request.rb:38:in `make_request'
    from /.rvm/gems/ruby-1.9.3-p194@myapp/gems/serel-1.0.1/lib/serel/request.rb:17:in `execute'
    from /.rvm/gems/ruby-1.9.3-p194@myapp/gems/serel-1.0.1/lib/serel/relation.rb:129:in `request'
    from /.rvm/gems/ruby-1.9.3-p194@myapp/gems/serel-1.0.1/lib/serel/relation.rb:113:in `get'
    from /.rvm/gems/ruby-1.9.3-p194@myapp/gems/serel-1.0.1/lib/serel/tag.rb:17:in `find_by_name'
    from /myapp/lib/tag_fetcher.rb:8:in `find_tag'

This can be replicated by simply doing this:

 > Serel::Tag.find_by_name('c#')
[INFO][2013-02-25 02:26:44] Making request to /2.0/tags/c#/info?site=stackoverflow&key=mykey
JSON::ParserError: 743: unexpected token at '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>

There a suitable workaround for this, other than skipping the tag?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I imagine the API is returning a Bad Request response because the hash mark isn't properly encoded in the URL.

As Serel doesn't appear to attempt to encode the passed-in values at the moment, you should be able to get things working by calling Serel::Tag.find_by_name('c%23') instead.

share|improve this answer
    
Perfect. Thanks much! –  marcamillion Feb 25 '13 at 8:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .