简体   繁体   中英

Create/insert event (Google Calendar API v3) via HTTP Post > “400: Missing end time”

I am using FileMaker to interact with the Google Calendar API. I have managed to authorize my app, get a list of user's calendars and a list of events in those calendars and details for those events. However, I am having trouble creating events.

I make the following HTTP POST request. Header: Content-Type : application/json, Authorization : Bearer access_token

https://www.googleapis.com/calendar/v3/calendars/ **********@gmail.com/events?{"attachments":[{"fileUrl":""}],"attendees":[{"email":"***********@gmail.com"}],"end":{"dateTime":"2017-08-20T13:00:00-05:00"},"reminders":{"useDefault":true},"start":{"dateTime":"2017-08-20T12:00:00-05:00"},"summary":"Test Event"}

I receive the following JSON error response:

{
    "error": 
    {
        "errors": 
            [
                {
                    "domain": "global",
                    "reason": "required",
                    "message": "Missing end time."
                }
            ],
        "code": 400,
        "message": "Missing end time."
    }
}

It appears that this is a pretty common error that people run into. However it looks like most having this problem are using frameworks for which there are libraries that Google Calendar API supports. I've tried to pick out the fix from some of the posts on stackoverflow and elsewhere concerning these other frameworks and apply them to my FileMaker / HTTP GET/POST setup to no avail.

Any help greatly appreciated!

Try using this instead.

POST https://www.googleapis.com/calendar/v3/calendars/calendarId/events

And supply the calendarId according to what the parameter requires

Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.

Use this

curl --location --request POST 'https://www.googleapis.com/calendar/v3/calendars/{email}/events' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: text/plain' \
--data-raw '{`enter code here`
  "summary": "Google I/O 2015",
  "location": "800 Howard St., San Francisco, CA 94103",
  "description": "A chance to hear more about Google'\''s developer products.",
  "start": {
    "dateTime": "2015-05-28T09:00:00-07:00",
    "timeZone": "America/Los_Angeles"},
  "end": {
    "dateTime": "2015-05-28T17:00:00-07:00",
    "timeZone": "America/Los_Angeles"
  },
  "recurrence": [
    "RRULE:FREQ=DAILY;COUNT=2"
  ],
  "attendees": [
    {"email": "lpage@example.com"},
    {"email": "sbrin@example.com"}
  ],
  "reminders": {
    "useDefault": false,
    "overrides": [
      {"method": "email", "minutes": 24},
      {"method": "popup", "minutes": 10}
    ]
  }
}'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM