Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6699349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:41:06+00:00 2026-05-26T06:41:06+00:00

I am facing an exception while using Google translation API V2. Exception text is

  • 0

I am facing an exception while using Google translation API V2. Exception text is “The remote server returned an error: (403) Forbidden”. Exception occurs when req.GetResponse()function called. I am using following code. Please mention if any correct code is available.
Thanks

public static string Translate()
    {
         String textToTranslate = "Common";
         String fromLanguage = "en"; // english
         String toLanguage = "ur"; // spanish
         String apiKey = /*My API Key*/; 

        // create the url for making web request
         String apiUrl = "https://www.googleapis.com/language/translate/v2?key={0}&source={1}&target={2}&q={3}";
         String url = String.Format(apiUrl, apiKey, fromLanguage, toLanguage, textToTranslate);    
         string text = string.Empty;

        try
        {
            // create the web request
            WebRequest req = HttpWebRequest.Create(url);

            // set the request method
            req.Method = "GET";

            // get the response
            using (WebResponse res = req.GetResponse())
            {
                // read response stream
                // you must specify the encoding as UTF8 
                // because google returns the response in UTF8 format
                using (StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8))
                {
                    // read text from response stream
                    text = sr.ReadToEnd();
                }
            }
        }
        catch (Exception e)
        {
            throw; // throw the exception as is/
        }

        // return text to callee
        return text;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:41:07+00:00Added an answer on May 26, 2026 at 6:41 am

    You either run into some Google-set API usage limit (see http://code.google.com/apis/language/translate/v2/getting_started.html)

    OR

    The problem lies in the language (ur = Urdu ?) you are using… you should check whether this combination is actually available via the respective API. If you really want spanish as your comment suggests I suspect that would be es.

    Another point:
    You are not escaping your URL parameters (esp. the text to be translated) which in turn could lead to some problems in the future…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In fact I have Idea about the exception handling. But while facing the interview
These are some general questions I am facing while designing the error handling for
I am facing problem while GWT compilation. I am using ANT build file in
Hi guys I am using entity framework, I am facing some problem while checking
I am facing problem on a centOS server while sending java mails. Getting the
I am facing problem while trying to open a simple text file in C#.
I am constantly facing this error while testing. I cannot even create an instance
I'm facing an Out of Memory Exception while converting a 1.8MB image to bytes
I am using WCF service in my client-server application and I am facing following
I have a problem that I am facing OuOfMemory Error while printing a string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.