Varshini
Varshini

Reputation: 199

Cannot fetch the Google Calendar name through API using Calendar ID

I need to fetch the calendar Name from the calendar ID. I've given the correct Google Calendar ID and sent it through api to fetch the calendar details and get the calendar name.

    https://www.googleapis.com/calendar/v3/calendars/en.indian#[email protected]

    Method type: GET
    Content-Type: application/json
    Authorization: Bearer <latest access_token>

I've checked it with Google Calendar API online, it is working fine. But when i pass it through postman or in my java code, the following json is recieved.

    {
      "error": {
        "errors": [
          {
            "domain": "global",
            "reason": "notFound",
            "message": "Not Found"
          }
        ],
        "code": 404,
        "message": "Not Found"
      }
    }

This error occurs only when i give the default calendar ID's like en.indian#[email protected](Holidays in India)

Upvotes: 0

Views: 3597

Answers (2)

Sreejan
Sreejan

Reputation: 1

Convert # to %23.
The URL removes # and after.

Refer to this link.

Upvotes: 0

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116958

To get the information about a calendar you should use

Calendar.get Returns metadata for a calendar.

Request (note access token):

GET https://www.googleapis.com/calendar/v3/calendars/en.indian#[email protected]?access_token=youraccesstoken

Response

{
 "kind": "calendar#calendar",
 "etag": "\"fBXC91rAg76NkSpaCdEoUEir1ww/pR1e1Z3gR0361TBF8mRGGxGD_VM\"",
 "id": "en.indian#[email protected]",
 "summary": "Holidays in India",
 "timeZone": "Europe/Copenhagen"
}

This call requires that you be authenticated yes even for a public calendar.

Calendar list will only work if the user who has authenticated has added this calendar to there calendar list.

Calendarlist.get

request

GET https://www.googleapis.com/calendar/v3/users/me/calendarList/en.danish#[email protected]?access_token=youraccesstoken

Response

{
 "kind": "calendar#calendarListEntry",
 "etag": "\"1442929251602000\"",
 "id": "en.danish#[email protected]",
 "summary": "Holidays in Denmark",
 "timeZone": "Europe/Copenhagen",
 "colorId": "11",
 "backgroundColor": "#fbe983",
 "foregroundColor": "#000000",
 "selected": true,
 "accessRole": "reader",
 "defaultReminders": []
}

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

Scope https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar

Note: My calendars is a list of calendars that the user in question has created. Other calendars is a list of calendars that was shared with the user.

Upvotes: 1

Related Questions