Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST request Google Calendar results in "Parse Error" #7

Open
sanneterpstra opened this issue Oct 27, 2015 · 12 comments
Open

POST request Google Calendar results in "Parse Error" #7

sanneterpstra opened this issue Oct 27, 2015 · 12 comments

Comments

@sanneterpstra
Copy link

I'm trying to integrate Google Calendar in my meteor app. Reading events goes fine but when I try to create an event by using the post request I'm getting a Parse Error.

This is the code for the request (using Google's example code):

    var result = HTTPJWT.post("https://www.googleapis.com/calendar/v3/calendars/{My calendar id}/events", {
        headers: {
            'Content-Type': 'application/json ; charset=UTF-8"'
        },
        params: {
            'summary': 'Google I/O 2015',
            'location': '800 Howard St., San Francisco, CA 94103',
            'description': 'A chance to hear more about Google\'s developer products.',
            'start': {
                'dateTime': '2015-05-28T09:00:00-07:00',
                'timeZone': 'America/Los_Angeles'
            },
            'end': {
                'dateTime': '2015-05-28T17:00:00-07:00',
                'timeZone': 'America/Los_Angeles'
            }
        }
    });

However the response I'm getting back is an Parse Error with no additional information.
Error: failed [400] { "error": { "errors": [ { "domain": "global", "reason": "parseError", "message": "Parse Error" } ], "code": 400, "message": "Parse Error" } }

@lukejagodzinski
Copy link
Owner

It's the response from the server so it's not a problem with the package, so you shouldn't ask it here. Have you tried inserting only the summary?

@sanneterpstra
Copy link
Author

Thanks for the quick response!

When I only insert the summary it still responds with a parseError. I tried using your suggested code in this issue:

var result = HTTPJWT.post('https://www.googleapis.com/calendar/v3/calendars/{YOUR_CALENDAR_ID}/events', {
    params: {
        'summary': 'Google I/O 2015'
    }
});

But then I get the following error:

Error: failed [400] {  "error": {   "errors": [    {     "domain": "global",     "reason": "parseError",     "message": "This API does not support parsing form-encoded input."    }   ],   "code": 400,   "message": "This API does not support parsing form-encoded input."  } } 

I'm not sure what to do.. Could you please help me with this?

@lukejagodzinski
Copy link
Owner

Have you tried without setting headers? It's hard to tell what is the reason.

@sanneterpstra
Copy link
Author

Yes I also tried without headers but then the API says it doesn't support form-encoded input. When setting the headers to JSON, the form-encoded parse error goes away but then it just gives a parse error. And when using a JSON header without any params it says it needs an end date.

So it seems that the API only accepts JSON formatted data but when I give it JSON data by putting it in the params it returns a parse error without any further information.

@lukejagodzinski
Copy link
Owner

You know, it's hard to predict what is the source of the error. I've created this package to access Google Endpoint API. It's based on the node.js package. It worked well in my project. I haven't tested it with Calendar API. However as you said it work on getting values but you can't insert. What I would suggest is checking in Google Chrome Developer Tools what requests are send when using this package and what requests are send using the Google Sandbox. Thanks to that you may compare the data and see a difference.

@shamoon1992
Copy link

invalidRequest (HTTP status 400): Your request was not a valid request.

@lukejagodzinski
Copy link
Owner

@shamoon1992 and? :)

@MVakas
Copy link

MVakas commented Dec 12, 2015

Hi have you resolved this? I’m having the same issue.

@vasiledoe
Copy link

same fucking error!!!!!

@osman-masood
Copy link

osman-masood commented Jun 25, 2018

I'm also getting this error response from Google when trying to create a calendar event.

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "parseError",
    "message": "Parse Error"
   }
  ],
  "code": 400,
  "message": "Parse Error"
 }
}

I'm only setting a start.dateTime and end.dateTime and nothing else (though I've also tried setting a summary and description, but get the same thing).

POST https://www.googleapis.com/calendar/v3/calendars/primary/events?access_token=my_valid_access_token
Accept: application/json
{"start":{"dateTime":"2018-07-02T13:41:55Z"},"end":{"dateTime":"2018-07-02T13:56:55Z"}}

EDIT

I found the solution. It was that I was simply missing the Content-Type header. I guess it would've been nice if it told me that. Either way, yay!

@mehtakovid
Copy link

Even after adding contentType("application/json\r\n") still seeing the same error. Tried hitting it on google API explorer works like charm but with rest assured it just gives the same error again. Has anyone found any other solution to the issue ?

@rsulca8
Copy link

rsulca8 commented Apr 17, 2021

I'm also getting this error response from Google when trying to create a calendar event.

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "parseError",
    "message": "Parse Error"
   }
  ],
  "code": 400,
  "message": "Parse Error"
 }
}

I'm only setting a start.dateTime and end.dateTime and nothing else (though I've also tried setting a summary and description, but get the same thing).

POST https://www.googleapis.com/calendar/v3/calendars/primary/events?access_token=my_valid_access_token
Accept: application/json
{"start":{"dateTime":"2018-07-02T13:41:55Z"},"end":{"dateTime":"2018-07-02T13:56:55Z"}}

EDIT

I found the solution. It was that I was simply missing the Content-Type header. I guess it would've been nice if it told me that. Either way, yay!

Thanks! that was. I had " ContentType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants