-1

I am working with the google calendar api and i was wondering if it was possible to patch/update the responsestatus of an invitee. I am able to access the google calendar of the users and insert, delete and update their google calendar. But I do not know how I can change the responsestatus for an user.

This is my patchdate function where I am trying to patch an event.

   function patchDate(calendarid, dateFormat) {
        gapi.client.load('calendar', 'v3', function() {                 // load the calendar api (version 3)
            var request = gapi.client.calendar.events.patch({
                'calendarId':       'primary',  // calendar ID
                "eventId": calendarid,      // pass event id
                "sendNotifications": true,
                "resource":         dateFormat      // pass event details with api call
            });

            // handle the response from our api call
            request.execute(function(resp) {
                if(resp.error || resp == false) {
                    console.log("failed to update")
                } else {
                    console.log("successfully updated")
                }
                console.log(resp);
            });
        });
    }

This is how I call my function. I am passing in the user email that I want to patch. There are multiple emailaddresses in the google calendar event but I only want to change one of them. In this case this would be the example@.com

var dateFormat = {
    "email": 'example@.com',
    "responseStatus": 'accepted'
};
patchDate(tableData[6], dateFormat)

I get a 200 ok response when I try patching an event but the responsestatus does not change.

This is the response I get

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
John
  • 97
  • 1
  • 7
  • Have you tried on the Try This part from the [API documentation](https://developers.google.com/calendar/v3/reference/events/patch). Is the result the same? – Kessy Jan 12 '21 at 13:57
  • @Kessy I think its the same result but with different implementation. The implementation I use is from the google calendar quickstart tutorial so it should be working also. Here is the full implementation im using. https://developers.google.com/calendar/quickstart/js – John Jan 12 '21 at 14:28

2 Answers2

1

If you check the documentation for event resource it appears that responseStatus is writeable.

enter image description here

Your code looks fine to me but if its not working then i would suggest you submit an issue to the issue forum

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • I forgot to tell that im trying to patch the event as the invitee not as the organizer. So basically im logged in as example@.com and im trying to change my own status in the event. Would this make a difference on why it doesnt work? – John Jan 12 '21 at 11:05
  • Well its not giving you an error, so i would gather you have authorized the user with write scope. Now I would assume that the user would have permission to change their own status. That being said the question would be who's permission does it use for write access the user whos permission we are trying to change or the owner of the event. – Linda Lawton - DaImTo Jan 12 '21 at 12:51
  • I also couldn't change the response status of an invitee as an organizer. Is there a possibility to do this with update instead of patch? – John Jan 12 '21 at 13:19
  • Try with update but use event.get then use the response to post back to the Update. You need all the fields. If that doesnt work i would put it up on the issue forum i have a message out to a couple of people waiting to hear back. – Linda Lawton - DaImTo Jan 12 '21 at 13:27
  • 1
    Alright im new to all of this so I do not really understand how to make it without alot of tutorial vids but I will try it out thanks. By the way I also submitted an issue on the issue form like you suggested. – John Jan 12 '21 at 13:46
  • 1
    As far as i can tell your doing everything correct and the documentation does state its writeable. – Linda Lawton - DaImTo Jan 12 '21 at 13:48
1

Your dateFormat object should be wrapped within the "attendees":[] object which you are missing, hence your patch isn't being applied. the "resource" should look like the following:

"resource": {
        "attendees": [
          {
            "responseStatus": "tentative",
            "email": "example@.com"
          }
        ]
      }

You could change your dateFormat to

var newDateFormat = {"attendees":[dateFormat]}

I did it with the Try this here: https://developers.google.com/calendar/v3/reference/events/patch#try-it

Aerials
  • 4,231
  • 1
  • 16
  • 20