访问谷歌API时出现错误400错误请求

时间:2016-01-03 00:23:02

标签: android api freebase

我正在尝试访问google Knowledge图形API,但遇到错误com.google.api.client.http.HttpResponseException: 400 Bad Request "message": "API key not valid. Please pass a valid API key.",但我没有得到它,我的API密钥是我根据提供的说明获得的正确密钥here < / p>

  HttpTransport httpTransport = new NetHttpTransport();
        HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
        JSONParser parser = new JSONParser();
        GenericUrl url = new GenericUrl("https://kgsearch.googleapis.com/v1/entities:search");
        url.put("query", "Taylor Swift");
        url.put("limit", "10");
        url.put("indent", "true");
        url.put("key",R.string.API_KEY);
        HttpRequest request = requestFactory.buildGetRequest(url);
        HttpResponse httpResponse = request.execute();

0 个答案:

没有答案