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.

I just noticed something in my testing. I was searching for questions tagged "C#" and the questions come back tagged "C".

Code Poet's SOAPI javascript formats the route thusly:

http://api.stackoverflow.com/1.0/questions?tagged=c%23&sort=activity&order=desc

His works, whereas mine includes the "#" even when I HttpUtility.HtmlEncode it. What am I missing, and is there a quick and dirty converter?

share|improve this question
    
++ for the assist –  Sky Sanders Jul 24 '10 at 2:48
add comment

2 Answers 2

up vote 5 down vote accepted

Use UrlEncode not HtmlEncode.

# is legal in HTML, but a restricted character in URLs.

share|improve this answer
1  
++ good catch. I didn't even notice that. –  Sky Sanders Jul 24 '10 at 1:26
1  
+1 Yet another facepalm/headsmack. Thank you Mr. Kevin. –  Dave Swersky Jul 24 '10 at 1:38
add comment

I will write a test in Soapi.CS to see how it goes. C#<->JS is apples/oranges as the browser is pretty good at taking care of those things.

looks like soapi.cs is not handling it well either.

http://api.stackoverflow.com/1.0/search?intitle=C%2523

apparently I am double urlencoding. or maybe i am encoding when I don't need to and the webrequest is encoding it again. I suspect that is the case.

Not sure why you are simply dropping the hash. I will post findings later tonight.

Thanks, Dave. Misreading your question helped me track down a bug in my code! I was encoding each parameter and then again when I build the query.

share|improve this answer
    
Normally I would agree with you, but if you go to that route in your browser and use the "#" instead of the "%23" you'll get different results. –  Dave Swersky Jul 24 '10 at 1:11
    
If you try this in StackMobile, you'll see that the '#' is converted to '%23' as per Kevin's answer. The reason I say this is because I made this mistake too originally :) –  Nathan Osman Jul 24 '10 at 6:24
add comment

You must log in to answer this question.

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