How to Insert Event in Google Calendar

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

Have you done this step?

1 Like

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.

1 Like

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

2 Likes

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

function doPost(event) {
   return CalendarApp.getDefaultCalendar().createEventFromDescription(event.parameter.eventDesc);
 }
1 Like

I tested the same code and this is the result
image

This is the code I deployed

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

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

2 Likes

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

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.

1 Like

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

1 Like

How would I troubleshoot either one of those?

I donā€™t see how it could be either one

1 Like

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.

1 Like

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

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.


1 Like

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

1 Like

I get the following

1 Like

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.

1 Like

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

1 Like

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.

1 Like

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?

1 Like

Congrats.

1 Like

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