I'm trying to send POST request to google calendar's free-busy service on my flask dance extension. But I'm getting "405 Method Not Allowed" error. I don't know how to debug it.
I have to pass JSON data in the request body. I have referred request documentation . I'm new to flask and flask dance any help would be appreciated.
@app.route("/",methods=['POST'])
def free():
if not google.authorized:
return redirect(url_for("google.login"))
event = json.dumps({"timeMin": "2019-03-31T00:00:00Z",
"timeMax": "2019-04-01T00:00:00Z",
"timeZone": " Asia/Calcutta",
"groupExpansionMax": 3,
"calendarExpansionMax": 1,
"items": [
{
"id": "abcd@gmail.com"
}
]
})
resp = google.post(url="https://www.googleapis.com/calendar/v3/freeBusy",data=event)
return resp.json()
response should be json data
"timeMax": "2019-04-01T00:00:00.000Z",
"kind": "calendar#freeBusy",
"calendars": {
"abcd@gmail.com": {
"busy": [
{
"start": "2019-03-31T03:00:00Z",
"end": "2019-03-31T09:00:00Z"
}
]
}
},
"timeMin": "2019-03-31T00:00:00.000Z"
}```
Added GET with POST, now code seems to work
@app.route("/",methods=['GET','POST'])
def free():
if not google.authorized:
return redirect(url_for("google.login"))
event = {"timeMin": "2019-03-31T00:00:00Z",
"timeMax": "2019-04-01T00:00:00Z",
"timeZone": " Asia/Calcutta",
"groupExpansionMax": 3,
"calendarExpansionMax": 1,
"items": [
{
"id": "abcd@gmail.com"
}
]
}