Click here to Skip to main content
15,887,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI guys ,
 
"http://www.google.com/transliterate/indic?tlqt=1&langpair=en|hi&text=" + HttpUtility.UrlEncode("India") + "&from=en&to=hi;
 
I have some issue when i am calling this url from code behind .
 
The remote server returned an error: (404) Not Found this error i'm getting.
 
but if i directly put this URL then it is working file is also downloading.


What I have tried:

uri = "http://www.google.com/transliterate/indic?tlqt=1&langpair=en|hi&text=" + HttpUtility.UrlEncode("India") + "&from=en&to=hi;
HttpWebRequest translationWebRequest = (HttpWebRequest)WebRequest.Create(uri);
WebResponse response = null;
response = translationWebRequest.GetResponse();// in this line error is coming
Stream stream = response.GetResponseStream();
Encoding encode = Encoding.GetEncoding("utf-8");
StreamReader translatedStream = new StreamReader(stream, encode);
 
Can any one help me ... how to solve this error!
Posted
Updated 21-Feb-19 1:15am
Comments
Bohdan Stupak 19-Feb-19 8:18am    
I wonder how it compiles because you're missing a closing quote here "&from=en&to=hi";
But I after I copy paste your code, close the quote and execute it, I get 200 instead of 404
ZurdoDev 19-Feb-19 13:26pm    
Compare the 2 strings. Something is different if one works and one doesn't.
Richard Deeming 20-Feb-19 8:12am    
NB: The Google Transliteration API[^] was deprecated in 2011. I'm surprised the web version is still working.

1 solution

This is absolutely working for me.

C#
var uri = "http://www.google.com/transliterate/indic?tlqt=1&langpair=en|hi&text=India&from=en&to=hi";
            var translationWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri);
            var response = translationWebRequest.GetResponse();
            System.IO.Stream stream = response.GetResponseStream();
            Encoding encode = Encoding.GetEncoding("utf-8");
            System.IO.StreamReader translatedStream = new System.IO.StreamReader(stream, encode);

            var resp = translatedStream.ReadToEnd();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900