Reputation: 1586
As part of an app I am working on, I would like to provide a list of holidays. I am attempting to use the Google API to do this. Before writing the code, I just want to have a look at what the JSON that is returned looks like.
I set up an account in Google, got an API key, and got set up to use the Google Calendar API. I did research on the HTML needed to get a list of holidays, but cannot seem to get it to work. I went through all of the Calendar API documentation and did not find anything about retrieving a list of holidays. Here are some of the URLs that I tried, and the responses that I received. I found all of these URL examples online (mostly here). I've removed my API key.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
https://www.googleapis.com/calendar/v3/calendars/en.sa%[email protected]/events?key=myKey
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?key=myKey
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
https://www.googleapis.com/calendar/v3/calendars/en.usa#[email protected]/events?key=myKey
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Google is seeing my requests, and they are all errors.
It seems like the URLs that I've found online might have worked at one time, but no longer seem to work.
Is there any update on how to use this?
Update: I tried the information on the answer below and now I get this:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
I tried en.danish#[email protected]
in the Try This API section of the Events:List API reference and I was able to get the JSON for the dates. I do not understand why it works in Try This API, but it is not working from url. The latest url that I tried:
https://www.googleapis.com/calendar/v3/calendars/en.danish#[email protected]/events?key=myKey
Upvotes: 0
Views: 1676
Reputation: 9
For me it works but without the language in front of the country.
https://www.googleapis.com/calendar/v3/calendars/uk%40holiday.calendar.google.com/events?key=YOURKEY
Which is annoying for non english speaking countries like mine.
Upvotes: 0
Reputation: 5642
I was able to solve this issue by url encoding the #
and @
in the Public Calendar ID.
In my case:
en.new_zealand#[email protected]
becomes:
en.new_zealand%23holiday%40group.v.calendar.google.com/events
Until I did that, I was receiving a 401 error.
Upvotes: 0
Reputation: 117176
There appears to be a bug in the api currently. Public apis should be accessible using an API key they are not anymore you need to be authenticated
Bug verification information
GET https://www.googleapis.com/calendar/v3/calendars/en.danish%23holiday%40group.v.calendar.google.com?key={YOUR_API_KEY}
Response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
If you use Oauth2 and authenticate yourself you get
{
"kind": "calendar#calendar",
"etag": "\"2IG_UfzQLHbZ3_DsNnNPPvIpYxU/iF_yglNpjvUgQba3YfGrk5JFgq4\"",
"id": "en.danish#[email protected]",
"summary": "Holidays in Denmark",
"timeZone": "Europe/Copenhagen",
"conferenceProperties": {
"allowedConferenceSolutionTypes": [
"eventHangout"
]
}
}
Upvotes: 0