Connecting Tech Pros Worldwide Help | Site Map

Help with Webclient

Newbie
 
Join Date: Jul 2008
Posts: 28
#1: Oct 12 '09
I am trying to use someones web service to obtain lyrics for songs. I am able to use the web service via Firefox, however when I use a Webclient I do obtain the same results. An example URL of the service is

http://webservices.lyrdb.com/lookup.php?q=Aerosmith|Love%20In%20An%20Elevator&f or=match&agent=test/1.0


However if I do

Expand|Select|Wrap|Line Numbers
  1.                 using (WebClient wc = new WebClient())
  2.                 {
  3.                     string request = wc.DownloadString("http://www.lyrdb.com/lookup.php?q=Aerosmith|Love In An Elevator&for=match&agent=test/1.0");
  4.  
  5.                 }
The request string does not give the same results I experience in Firefox.
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,148
#2: Oct 12 '09

re: Help with Webclient


Have you tried using HttpWebRequest instead?
Newbie
 
Join Date: Jul 2008
Posts: 28
#3: Oct 12 '09

re: Help with Webclient


No. But I figured it out. The API tells me to use

http://www.lyrdb.com/lookup.php?q=qu...ld&agent=agent

which seems to redirect me to

http://webservices.lyrdb.com/lookup....ld&agent=agent

changing the WebClient to use the site I get redirected to fixed the problem.
Reply