0

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.

https://www.googleapis.com/calendar/v3/calendars/en.uk%40holiday.calendar.google.com/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.sa%40holiday@group.v.calendar.google.com/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.uk%40holiday.calendar.google.com/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.uk@holiday.calendar.google.com/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#holiday@group.v.calendar.google.com/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.

enter image description here

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#holiday@group.v.calendar.google.com 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#holiday@group.v.calendar.google.com/events?key=myKey

Scott Kilbourn
  • 1,545
  • 6
  • 18
  • 40

3 Answers3

0

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 report here

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#holiday@group.v.calendar.google.com",
 "summary": "Holidays in Denmark",
 "timeZone": "Europe/Copenhagen",
 "conferenceProperties": {
  "allowedConferenceSolutionTypes": [
   "eventHangout"
  ]
 }
}
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • I tried generating a new key and it didn't make any difference. I've updated my original post with the results of trying this answer. Getting closer, I think. – Scott Kilbourn Feb 18 '19 at 14:03
  • What I don't understand is that on the Try This API page, when I select "use an api key to authorize your request", it works. – Scott Kilbourn Feb 26 '19 at 14:36
0

I was able to solve this issue by url encoding the # and @ in the Public Calendar ID.

In my case:

en.new_zealand#holiday@group.v.calendar.google.com

becomes:

en.new_zealand%23holiday%40group.v.calendar.google.com/events

Until I did that, I was receiving a 401 error.

Luke
  • 4,825
  • 2
  • 30
  • 37
0

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.

eftyuj
  • 9
  • 3