I work with the Google Drive API but the principle is the same.
You need to not just look at the status code but also the response data returned. Here is an example of a
Bad (Google Drive)
Request:
POST https://www.googleapis.com/oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 65
Expect: 100-continue
Connection: Keep-Alive
client_id=&client_secret=&grant_type=refresh_token&refresh_token=
and google's response data
HTTP/1.1 400 Bad Request
Vary: X-Origin
Content-Type: application/json; charset=UTF-8
Date: Tue, 07 Mar 2017 06:02:05 GMT
Expires: Tue, 07 Mar 2017 06:02:05 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34"
Accept-Ranges: none
Vary: Origin,Accept-Encoding
Transfer-Encoding: chunked
{
"error": "invalid_request",
"error_description": "Missing required parameter: refresh_token"
}
UPDATED
This is the API page for the endpoint that you are calling:
Events: watch | Google Calendar API | Google Developers[
^]
The document states that the request is a Json packet:
In the request body, supply data with the following structure:
{
"id": string,
"token": string,
"type": string,
"address": string,
"params": {
"ttl": string
}
}
Your data is in the incorrect form. So you are correctly receiving the
Parse Error response.
UPDATE 2 re: Authorization Error
You need to Authenticate first, to gain access to your private data, before you can post changes. Authentication is more than the code that you have provided for your problem. You need to complete the steps in the following link:
[
^]
Once you have resolved the Authorization Error, then you can try creating your webhook.