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 8815509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:23:51+00:00 2026-06-14T04:23:51+00:00

I’m having trouble using Google’s freebase API in my java code. As it appears,

  • 0

I’m having trouble using Google’s freebase API in my java code.
As it appears, my query is too large to send it in a GET method but I couldn’t find a way to send it as a POST.

This is the error I’m getting:

    com.google.api.client.googleapis.json.GoogleJsonResponseException: 414 Request-URI Too Large
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 414 (Request-URI Too Large)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}
  </style>
  <a href=//www.google.com/><img src=//www.google.com/images/errors/logo_sm.gif alt=Google></a>
  <p><b>414.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/freebase/v1/mqlread</code>... is too large to process.  <ins>That’s all we know.</ins>

    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:143)
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.execute(GoogleJsonResponseException.java:187)
    at com.google.api.client.googleapis.services.GoogleClient.executeUnparsed(GoogleClient.java:279)
    at com.google.api.client.http.json.JsonHttpRequest.executeUnparsed(JsonHttpRequest.java:207)
    at com.huawei.mdf.MQLReadService.doMqlRead(MQLReadService.java:67)
    at com.huawei.mdf.MQLReadService.main(MQLReadService.java:82)

Here’s the code:

public void doMqlRead(String id, QueryType queryType) {

    HttpTransport httpTransport = new NetHttpTransport();
    JsonFactory jsonFactory = new JacksonFactory();
    HttpRequestInitializer httpRequestInitializer = new HttpRequestInitializer() {
        @Override
        public void initialize(HttpRequest arg0) throws IOException {
            // TODO Auto-generated method stub

        }
    };

    JsonHttpRequestInitializer requestInitializer = new JsonHttpRequestInitializer() {
        public void initialize(JsonHttpRequest jsonHttpRequest)
                throws IOException {
            FreebaseRequest freebaseRequest = (FreebaseRequest) jsonHttpRequest;
            freebaseRequest.setPrettyPrint(true);
            freebaseRequest.setKey(API_KEY);
        }
    };

    Freebase.Builder fbb = new Freebase.Builder(httpTransport, jsonFactory,
            httpRequestInitializer);

    Freebase freebase = fbb.setJsonHttpRequestInitializer(
            requestInitializer).build();

    List<String> queryList = QueryUtil.getQuery(queryType);
    for (String query : queryList) {
        query = query.replace("idreplace", id);
        System.out.println(query.length());

        try {
            Mqlread mqlread = freebase.mqlread(query);
            mqlread.setIndent(indentation);

            HttpResponse executeUnparsed = mqlread.executeUnparsed();
            String parseAsString = executeUnparsed.parseAsString();
            System.out.println(parseAsString);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

I have also tried to change this part in Freebase class (line 450) by switching the HttpMethod.GET part into HttpMethod.POST, but I’m sure that it’s not correct way:

/**
     * Internal constructor. Use the convenience method instead.
     */
    Mqlread(String query) {
        super(Freebase.this, HttpMethod.GET, REST_PATH, null);
        this.query = Preconditions.checkNotNull(query,
                "Required parameter query must be specified.");
    }

Is there a way of doing this?

  • 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-06-14T04:23:52+00:00Added an answer on June 14, 2026 at 4:23 am

    There doesn’t appear to be a way to override the HTTP method of an API call from within the Google API client library. You’ll have to build the request object yourself like this:

    HttpTransport httpTransport = new NetHttpTransport();
    HttpRequestFactory httpRequestFactory = httpTransport.createRequestFactory();
    
    String data = "query=" + query;
    HttpContent content = new ByteArrayContent("application/x-www-form-urlencoded", data.getBytes());
    GenericUrl url = new GenericUrl("https://www.googleapis.com/freebase/v1/mqlread");
    
    HttpRequest request = httpRequestFactory.buildPostRequest(url, content);
    HttpHeaders headers = new HttpHeaders();
    headers.put("X-HTTP-Method-Override","GET");
    request.setHeaders(headers);
    
    HttpResponse response = request.execute();
    

    Note that I’ve set the X-HTTP-Method-Override header so that this request gets handled as a GET request on the server side.

    I’ve filed a bug for the client library to handle this automatically.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.