Google Calendar Api bad request 400 events for the developer console

I created a project and registered it using https://code.google.com/apis/console (I chose a "different" type of application). Then I got a "Client ID" for installed applications.

Then I went to the console and created an event and allowed to use oauth 2. https://developers.google.com/google-apps/calendar/v3/reference/events/insert Everything worked fine.

POST https://www.googleapis.com/calendar/v3/calendars/primary/events?key={YOUR_API_KEY} Content-Type: application/json Authorization: xxx X-JavaScript-User-Agent: Google APIs Explorer { "end": { "dateTime": "2013-1-16T10:00:00.000-07:00" }, "start": { "dateTime": "2013-1-16T10:00:00.000-07:00" } } 

Answer

 200 OK - Show headers - { "kind": "calendar#event", "etag": "\"WANTVF5ixxZ04U_VtQ0AZ3MbAlM/Z2NhbDAwMDAxMzY1NjU0MzAwNTk1MDAw\"", "id": "2nsuis19mkp2q0uef54tl5nk68", "status": "confirmed", "htmlLink": "https://www.google.com/calendar/event?eid=Mm5zdWlzMTlta3AycTB1ZWY1NHRsNW5rNjggaXZhbjEzMzEzM0Bt", "created": "2013-04-11T04:25:00.000Z", "updated": "2013-04-11T04:25:00.595Z", "creator": { "email": " ivan133133@gmail.com ", "displayName": "ivan rozhcov", "self": true }, "organizer": { "email": " ivan133133@gmail.com ", "self": true }, "start": { "dateTime": "2013-01-16T21:00:00+04:00" }, "end": { "dateTime": "2013-01-16T21:00:00+04:00" }, "iCalUID": " 2nsuis19mkp2q0uef54tl5nk68@google.com ", "sequence": 0, "reminders": { "useDefault": true } } 

Then I copied the id and updated this event. https://developers.google.com/google-apps/calendar/v3/reference/events/update update The first time I got a 200 response.

 PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/2nsuis19mkp2q0uef54tl5nk68?key={YOUR_API_KEY} Content-Type: application/json Authorization: Bearer ya29.AHES6ZRmo6pdxj8pY4NmzdI1estRNB-v87XV7xQHgyhrWHk2rzs3Ke8 X-JavaScript-User-Agent: Google APIs Explorer { "end": { "dateTime": "2013-1-16T10:00:00.000-07:00" }, "start": { "dateTime": "2013-1-16T10:00:00.000-07:00" } } 

But when I tried it again, I always had 400 errors, the error text is written below.

https://developers.google.com/google-apps/calendar/v3/reference/events/update update

 400 Bad Request cache-control: private, max-age=0 content-encoding: gzip content-length: 123 content-type: application/json; charset=UTF-8 date: Wed, 10 Apr 2013 12:49:29 GMT expires: Wed, 10 Apr 2013 12:49:29 GMT server: GSE { "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid Value" } ], "code": 400, "message": "Invalid Value" } } 

Can someone explain if this is google.api error, or maybe I'm wrong somewhere?

I tried it with differret account and PC (via Google API Explorer and python library with the same result)

Today I tried to reproduce this error. But now everything is working fine. I created a problem in google code http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3371&thanks=3371&ts=1365599378 Still unanswered.

I think it was a mistake of the time.

+2
source share
4 answers

400 almost always means a simple syntax error in your authorization url. The most common reason is that you were either unable to leave the URL of your area or redirect, or, alternatively, using URLs that were not executed more than once.

+3
source

I used the patch instead of updating, and now it works great. But do not understand why the update occurred the first time and did not pass the second and second time. The complete mystery.

+1
source

Check this: Google Calendar API - can update the event only once and this: Google Calendar api v3 update problem

After changing the date / time of the event, you need to increase the number of sequences, so you get 400 - an unsuccessful request.

This is how I solved it using the java client library.

mGoogleCalendarEvent contains updated event information. First, get the sequence number of this event from GoogleCalendar:

 mGoogleCalendarEvent.setSequence(mService.events().get(mCalendarId,mGoogleCalendarEvent.getId()).execute().getSequence()); 

And then do the update:

 mService.events().update(mCalendarId, mGoogleCalendarEvent.getId(),mGoogleCalendarEvent).execute(); 
+1
source

The same issue was found while accessing the Google Calendar API in the Google API Client Library for Javascript. This happens if I try to update the start date of the calendar event. Updating the final data without problems. Really strange.

Fortunately, I was able to fix this problem by replacing the update with a patch.

0
source

Source: https://habr.com/ru/post/947406/


All Articles