Freebase API User Rate Limit Exceeded - freebase

I got the foloowing error and I do not know how to solve it. I read the page but my problem is not the same as the writer problem (space in URL).
com.google.api.client.http.HttpResponseException: 403 Forbidden
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "userRateLimitExceededUnreg",
"message": "User Rate Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "User Rate Limit Exceeded. Please sign up"
}
}
I checked the page 1; they mentioned "Freebase allows developers a free quota of up to 100,000 (one hundred thousand) read calls per day per person" and I only quota 49886 read calls.Then I got this error and I do not know how to solve the problem.

I created a server key for using Freebase API. Also, I defined my query in follwoing way:
String query="https://www.googleapis.com/freebase/v1/topic"+mId+"?key=xxx";
GenericUrl url = new GenericUrl(query);
HttpRequest request = requestFactory.buildGetRequest(url)
HttpResponse httpResponse = request.execute();
JSONObject response = (JSONObject)parser.parse(httpResponse.parseAsString());
The mId is mid in Freebase corpus. In addition, I add the flowing catch based on this pageto prevent error since in each second we can only send 10 requests to Freebase server.
catch (HttpResponseException e) {
if (e.getStatusCode()== 403
&& (e.getContent().contains("userRateLimitExceededUnreg")
|| e.getContent().contains("uotaExceeded"))) {
System.out.println("sleep");
Thread.sleep((2^ n) *1000 + randomGenerator.nextInt(1001));
}

Related

Google calendar push notification, login required error

I am following the docs https://developers.google.com/calendar/v3/push#creating-notification-channels
I am trying to setup my channel to watch for changes to events, using postman I am posting to:
https://www.googleapis.com/calendar/v3/calendars/xxx/events/watch
[{"key":"id","value":"xxx#xxx.co.uk"},
{"key":"type","value":"web_hook"},
{"key":"address","value":"https://xxx.firebaseapp.com"},{"key":"key","value":"AIzaSyBkAEZGoQwB0f-Kmq4mCCzm93422up8oQw"}]
I keep getting the error below:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Any ideas why I am getting this? I can fetch data from the API ok.
You are getting the 401 "login required", it means that you are using an expired or invalid access.
Check this Google group discussion on how the process was done on getting the refresh token using the client ID and client secret to implement the authenticated and authorized API calls.
See also references:
Google calendar API returns error 401 'login required' on inserting event in public calendar
Error with Google Calendar API - 401 Login required when adding a calendar event
Using API Key to authenticate a request generates a 401 error

ASP.NET Application sample code: difficult json response

I choose ASP.NET Web Application and then Web API. I leave the Authentication at "Individual User Accounts" and create the project.
I have made no additional changes except to add an ajax call to api/Account/Register.
When I make a request with a password that is too simple I get the json response below - it seems really hard to work with.
Is there some method for working with this, or do I really need to access textStatus.responseJSON.ModelState.\_empty\_[0] to get a nice text response from this? Will all error messages follow this general response format for ASP.Net Application rest requests?
PS: Actually I don't even know how to deal with a property called \_empty\_ as textStatus.responseJSON.ModelState.\_empty\_[0] doesn't even work.
My textStatus object:
{
"readyState": 4,
"responseText": "{\"Message\":\"The request is invalid.\",\"ModelState\":{\"\":[\"Passwords must have at least one non letter or digit character. Passwords must have at least one uppercase ('A'-'Z').\"]}}",
"responseJSON": {
"Message": "The request is invalid.",
"ModelState": {
"_empty_": [
"Passwords must have at least one non letter or digit character. Passwords must have at least one uppercase ('A'-'Z')."
]
}
},
"status": 400,
"statusText": "Bad Request"
}
UPDATE:
This is the actual body of the response.
But I still don't know how to access the property whose name is "". And, I want to be sure that this is how all error messages will be returned to me.
{
"Message": "The request is invalid.",
"ModelState": {
"": [
"Passwords must have at least one non letter or digit character. Passwords must have at least one uppercase ('A'-'Z')."
]
}
}
UPDATE:
This seems to parse it pretty well. Is this about as good as it gets?
error: function (textStatus, errorThrown) {
var json = textStatus.responseJSON;
var message = json.Message;
if (json.ModelState) {
for (var i = 0; i < json.ModelState[''].length; i++) {
if (i == 0) message += "\n";
message += "\n" + json.ModelState[''][i];
}
}
alert(message);
}

401 (Unknown authentication scheme) when retrieving data for group-merbership

I am getting a 401 (Unknown authentication scheme) problem when retrieving data for group-membership.
My application uses IN.API.Raw for retrieving the data but generates the error message as 401 (Unknown authentication scheme).
The response is shown below:
{
"errorCode": 0,
"message": "Access to group-memberships denied",
"requestId": "6YW0D6JWWR",
"status": 403,
"timestamp": 1395933151070
}
and the JS code is below for the group-memberships.
IN.API.Raw("/people/~/group-memberships?count=100&start=0")
.result(function(result) {
jQuery('#ligroupslabel').html("<strong>To edit the group, simply choose from your list of groups below:</strong>");
for (var i = 0; i < result._total; i++) {
jQuery('#linkedInGroups ul').append(
"<li><a href=\"linkedin_connection\" onclick=\"saveGroup('" + result.values[i].group.id + "','" + result.values[i].group.name + "'); return false;\">" +
result.values[i].group.name + "</a></li>");
}
});
Error 401 = Your request may be alright, but there is the little problem of authentication. You have to provide some proof of who you are. You would usually have a header which gives an authentication scheme and some authentication information in the request.
You may not have supplied any authentication scheme at all; quite possible that you get the (not entirely accurate) error message "unknown authentication scheme" in that case.

YouTube Analytics API Error: Forbidden

I've authenticated and build my query and receive the 403 response as Forbidden.
I authenticated with using httr example
# 1. Find OAuth settings for google:
google <- oauth_endpoint(NULL, "auth", "token", base_url = "https://accounts.google.com/o/oauth2")
# 2. Register an application at https://code.google.com/apis/console#access
myapp <- oauth_app("google", "{my app id}.apps.googleusercontent.com", secret = "{my secret}")
# 3. Get OAuth credentials
cred <- oauth2.0_token(google, myapp, scope = "https://www.googleapis.com/auth/yt-analytics.readonly")
After authorizing in the browser the R console prints 'Authentication complete."
The query is
query <- "https://www.googleapis.com/youtube/analytics/v1/reports?
ids=channel%3D%3D{my channel id}
&start-date=2013-01-01
&end-date=2013-07-31
&metrics=views
&dimensions=day"
The token for authorization is passed in header as
token <- paste("Authorization: Bearer ",cred[[1]], sep="")
I've tried the request with both httr and RCurl
# RCurl
api.response <- getURL(query, httpheader = token)
# httr - I think this is the right way to add the token to the header
url_signer <- sign_oauth2.0(cred[[1]], as_header = TRUE)
api.response <- GET(query, config = url_signer)
The api.response is unfortunately not very descriptive
{
"error":
{
"errors":
[
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
I'm not sure where else to look and have read through the documentation.
From experience, a 403 Forbidden response from the analytics API can mean a few things about the video you're trying to pull analytic information for:
The video is private and not uploaded by you
You have not claimed ownership on the video
The video does not exist, or has been deleted by the uploader
The uploader account has been terminated
You have a claim on the video that falls under one of the following statuses:
Inactive
Potential
When in doubt, contact your partner manager/TAM. I hope this helps!

google-bigquery how to get datasetlist with https get?

I'm trying to get dataset list from bigquery webserver with https get
following the documentation here:
https://developers.google.com/bigquery/docs/reference/v2/datasets/list
i'm using slightly modified code from:
http://code.google.com/p/qt-google-bigquery/source/browse/manager_bigquery.cpp
getDatasetsList(QString strProjectID)
{
QString url = QString("https://www.googleapis.com/bigquery/v2/projects/%1/datasets?key=%2").arg(str_ProjectID).arg(this->api_key);
//Also tried without ?key= part
QNetworkRequest request;
request.setUrl( QUrl(url) ); //this also urlencodes
request.setRawHeader("Content-Type", "application/json");
request.setRawHeader("Authorization", (QString("Bearer %1").arg(m_Access_Token)).toLatin1());
//here i post the request as a http get asynchronously
}
i get back this error message:
Reply = "{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter is missing"
}
],
"code": 400,
"message": "Required parameter is missing"
}
}
Note:
I managed to run a query and get the results, so my access token seems to be valid, what am i doing wrong here?
SOLVED
Ah, actually the problem was in my coding, not the request, i posted it as a http post, not a get.
See answer in comment by original poster above - but basically make sure you are using GET instead of the POST method for an API call to list datasets. Other BigQuery API methods use POST, PUT, or PATCH.
https://developers.google.com/bigquery/docs/reference/v2/datasets/list

Resources