Reputation: 189
I have set up my API key, my client id, and my client secret, but when I run the sample code it gets to SearchListResponse searchResponse = search.execute();
and then throws a GoogleJsonResponseException
saying There was a service error 400 : Bad Request
.
Is there something else I need to change in the sample code?
Here is a link to the sample code.
Here is the stacktrace.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Bad Request",
"reason" : "keyInvalid"
} ],
"message" : "Bad Request"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at com.google.api.services.samples.youtube.cmdline.data.Search.main(Search.java:112)
There was a service error: 400 : Bad Request
Upvotes: 0
Views: 92
Reputation: 189
The issue was actually just that I had a space at the end of my API key, which made the key invalid.
Upvotes: 2
Reputation: 2421
The usageLimits suggest that you already use all your quota.
More information can be found in this answer or search for usagelimits youtube api
.
I do remember read in the documentation about this error.
You can try also get another API key and try again.
Upvotes: 0