# How to Insert Event in Google Calendar

**URL:** <https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722>\
**Category:** Web API's\
**Created:** [December 4, 2020, 7:29am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722 "2020-12-04T07:29:34Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 22, 2022, 11:02am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/24 "2022-03-22T11:02:43Z")

</div>

You need to first execute it from the script editor to process the authentication process then it will work.

Have you done this step?

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 22, 2022, 11:03am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/25 "2022-03-22T11:03:01Z")

</div>

Yes I did, I had to do it twice like the one before.  
Getting this error when I try, makes sense though bc I haven’t really defined it in the script.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/f/aff48be3dac7c6cbb76c78b2c3c2cfa5d313bf88.jpeg)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 22, 2022, 11:21am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/26 "2022-03-22T11:21:25Z")

</div>

Google want to confuse the rest of us by having both `parameter` and `parameters`. Check with one works for you

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/3/230d4d5141ae60f85870a92eab0674fb05e5342b.png)

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 22, 2022, 11:29am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/27 "2022-03-22T11:29:09Z")

</div>

I now have the following (parameter) but no success yet

```auto
function doPost(event) {
   return CalendarApp.getDefaultCalendar().createEventFromDescription(event.parameter.eventDesc);
 }

```

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 22, 2022, 11:46am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/28 "2022-03-22T11:46:05Z")

</div>

I tested the same code and this is the result  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/0/107dc6946b18031559288868d9630a82ba5559b0.png)

This is the code I deployed

```auto
function doGet(event) {
  CalendarApp.getDefaultCalendar().createEventFromDescription(event.parameter.eventDesc);
 }

```

**Note:**  
I use **doGet** because I can execute it directly from the web browser.

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 22, 2022, 11:51am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/29 "2022-03-22T11:51:23Z")

</div>

I see you’re using a doGet but I tried that as well using both parameter and parameters with no success.

Made sure to save the updates as I did them as well

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 22, 2022, 11:53am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/30 "2022-03-22T11:53:38Z")

</div>

Here’s the response I’m getting from the API.  
I don’t think there’s any sensitive info here.  
The status is 401 and the error returns blank.

I also tried changing the end of the script to manually entering test event today at 9AM and ran the script from Google scripts and it was successful in my calendar.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/9/091d31c69826a6922f20009abfdf09c11c4255ec.jpeg)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 22, 2022, 1:55pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/31 "2022-03-22T13:55:29Z")

</div>

> [@overshield](#):
>
> status is 401

This means either not able to reach the server or authentication issue.

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 22, 2022, 4:27pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/32 "2022-03-22T16:27:54Z")

</div>

How would I troubleshoot either one of those?

I don’t see how it could be either one

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 23, 2022, 8:00am UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/33 "2022-03-23T08:00:47Z")

</div>

To troubleshoot you need to understand the following:

- doGet and doPost cannot be tested from the Script editor so you cannot just hit the run button.
- doGet can be tested by placing the URL in the browser bar and add the parameters, here `eventDesc`.
- doPost requires a HTML form or Postman.

Once you pass this stage you can try it in Thunkable.

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 23, 2022, 1:03pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/34 "2022-03-23T13:03:14Z")

</div>

How do I make sure the app has authorization?  
Or does anyone w the url have the ability to make changes?

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 23, 2022, 1:46pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/35 "2022-03-23T13:46:29Z")

</div>

I didn’t have the access set to anyone, so now I’m getting 200. But for some reason the error at the bottom is saying function not found: doPost, but my function isn’t doPost, it’s doGet and I’ve saved it but it’s still saying that.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/f/6f3b45b66937e5ffc9cd9eadcf15fe8a307f7784.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/a/0a0e066860b192535bd842184df65c5767ac8431.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 23, 2022, 2:23pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/36 "2022-03-23T14:23:13Z")

</div>

Can you use the URL you obtained and test it directly in the browser. At the end of the URL add

**?eventDesc=test+meeting+9AM**

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 23, 2022, 2:24pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/37 "2022-03-23T14:24:35Z")

</div>

I get the following

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/3/a3306ae72f5fdd0ad5fb168ed92b1f0d60a27d21.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 23, 2022, 2:26pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/38 "2022-03-23T14:26:12Z")

</div>

Good. So it is a doGet as it says. We know it returns nothing so this is OK. Or you may need to redeploy.

Verify that an event was added to your calendar which should make it a success.

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 23, 2022, 2:55pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/39 "2022-03-23T14:55:57Z")

</div>

Even though it says not found?

I tried running it via the web and it did not add an event to my calendar.  
I modified it to have ‘test event, today 9AM’ and it does add the event if I run it from the scripts editor.  
Attempting to execute it via URL does not add **‘test event, today 9AM’** to my calendar

Changing it all back to **event.parameters.eventDesc** and running via URL does not add to the calendar, nor does trying to run it through the Thunkable app.  
Thunkable still says 200 but script function not found: doPost

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 23, 2022, 3:13pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/40 "2022-03-23T15:13:07Z")

</div>

> [@overshield](#):
>
> Even though it says not found?

Was referring that it says **doGet** not doPost. But it seems that something is wrong in deploying the function. Maybe it was not the selected function in the editor when you click **Deploy**.

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 23, 2022, 3:25pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/41 "2022-03-23T15:25:30Z")

</div>

I didn’t realize you have to redeploy if you change something, I thought save was sufficient.  
I get this now when using the URL

And it adds the event but it adds it to tomorrow instead of today, perhaps because 9AM has already passed?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/a/9a563dcf370ebdcc88dd9b735e0e70a1f898a915.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [March 23, 2022, 4:22pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/42 "2022-03-23T16:22:15Z")

</div>

> [@overshield](#):
>
> And it adds the event

Congrats.

---

<div class="post-metadata">

**Author:** ![overshield](https://avatars.discourse-cdn.com/v4/letter/o/e19b73/32.png) [@overshield](https://community.thunkable.com/u/overshield)\
**Post date:** [March 23, 2022, 4:51pm UTC](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722/43 "2022-03-23T16:51:03Z")

</div>

It doesn’t add it from the app though, only the URL and adds it tomorrow.

I’m still getting the “script function not found: doPost” error

[Previous page](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722.md?page=1)

[Next page](https://community.thunkable.com/t/how-to-insert-event-in-google-calendar/1019722.md?page=3)
