Jianping Huang
Jianping Huang

Reputation: 305

Google Calendar API event insert always return 404 "not found" error

I tried the calendar insert example from here : https://developers.google.com/google-apps/calendar/v3/reference/events/insert#examples No matter which property i use, i always get the 404 "not found" error. Anyone can shed some light on this? Many thanks!!!

POST https://www.googleapis.com/calendar/v3/calendars/test/events?sendNotifications=false&fields=start&key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.AHES6ZQaT3-Tj_bviwaY9Xi3gDspuBbCtEKtidnZkTXuWpI
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "end": {
  "date": "2012-07-11"
 },
 "start": {
  "date": "2012-07-09"
 }
}

response: 404 Not Found

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

Upvotes: 28

Views: 35225

Answers (6)

Today I had the same problem with non primary calendar. It's solved now, follow this steps:

  1. Go to Service Accounts, enter to your project, and create a Service account, then go to Key Tabs and create one Key, a Json file is saved now.

enter image description here

enter image description here

  1. Open Json and look at "client_email" attribute.

enter image description here

  1. Now go to your non primary calendar and go to Settings and sharing section.

enter image description here

  1. Now add the email it's set on "client_email" json attribute in the Share with specific people section.

enter image description here

  1. Test again, it's now working!

Note: This solution serve me with PHP web app with Service account auth method. You have to use Service account method too instead of OAuth 2.0.

Upvotes: 13

AmirRezaM75
AmirRezaM75

Reputation: 1140

I had the same issue.

I was sending request using guzzleHttp (I mean not any official SDKs)

One of my calendar's id is en.usa#[email protected] . and I needed to encode URL because of hashtag.

Upvotes: 1

Sunny
Sunny

Reputation: 9

There can be two problems: a). Either your calendar id is not correct. You can find it via following steps-

  1. In the Google Calendar interface, locate the "My calendars" area on the left.
  2. Hover over the calendar you need and click the downward arrow.
  3. A menu will appear. Click "Calendar settings".
  4. In the "Calendar Address" section of the screen, you will see your Calendar ID. It will generally your mail id or primary.

b) Daily limit of unauthenticated use may have exceed. Check it via https://www.googleapis.com/calendar/v3/calendars/primary12/events?alt=json primary12 is your calendar name

Upvotes: 1

Tomy
Tomy

Reputation: 61

To JuanPablo, Re non-primary calendar:

In case of non-primary calendar you have to use the id (in form of an email address) as the calendarId.

Example: Let's say you have a calendar named 'test'. You get its id like this

GET https://www.googleapis.com/calendar/v3/users/me/calendarList?key={YOUR_API_KEY}
->
{
 "kind": "calendar#calendarList",
...
 "items": [
  {

   "kind": "calendar#calendarListEntry",
   "etag": ...,
   "id": "[email protected]",
   "summary": "test",
   "description": "Testing calendar for development of Calendar related applications",
...
   }
  }
 ]
}

Your POST will then look like this

POST https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?sendNotifications=false&fields=start&key={YOUR_API_KEY}

Upvotes: 6

Himanshu Jain
Himanshu Jain

Reputation: 518

I am also getting the same problem with s=inserting the event, while getting a particular event. But i got an alternative just specify CalendarList asa = service.CalendarList.List().Execute(); before the execution of code where you are getting. I don't know the reason why it is running after specifying this code. If you find the correct way please update it here as it will consume more quota count.

Upvotes: -3

Matt Healy
Matt Healy

Reputation: 18531

I believe it's telling you that the calendar "test" resource cannot be found. Have you created a calendar called "test"? If you replace "test" with "primary" (your main calendar) then the Explorer should work.

Upvotes: 15

Related Questions