0

I'm using Java Google API client and I'm trying to create a Google Calendar Event. I'm able to login and fetch events I already have created.

I've been following the API examples and I'm getting the following error and looked at the other similar questions and still can't get it working:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
"domain" : "global",
"message" : "Invalid value for: \"T\" found, can only parse bare date string: 2017-08-31T12:00:00.000-01:00 Have you accidentally used DateTime instead of a Date?",
"reason" : "invalid"
  } ],
  "message" : "Invalid value for: \"T\" found, can only parse bare date string: 2017-08-31T12:00:00.000-01:00 Have you accidentally used DateTime instead of a Date?"
} 

This is my code, I'm passing Strings into my DateTimes:

DateTime startDate = new DateTime(startData);
    EventDateTime start = new EventDateTime();
    start.setDate(startDate);
    start.setTimeZone("Europe/Stockholm");
    DateTime endDate = new DateTime(endData);
    EventDateTime end = new EventDateTime();
    end.setDate(endDate);
    end.setTimeZone("Europe/Stockholm");
    Event event = new Event();
    event.setDescription(lessons.get(i).getDescription());
    event.setStart(start);
    event.setEnd(end);
    event.setLocation(lessons.get(i).getLocation());
    event.setSummary(lessons.get(i).getName())

Any idea what's going wrong?

1 Answer 1

1

Possible duplicate.

However, shortly - Yes, you are trying to use a function which require a DateTime format, but you feed as a parameter a date object which is different.

"new DateTime(startData);" startData isn't DateTime, but date.

Please checkout this post: Google Calendar API (Java) - Invalid time format when creating Google Calendar Event

it has your problem and two solutions for it.

Sign up to request clarification or add additional context in comments.

2 Comments

You're right, I hadn't correctly checked the other answer after all. I blame this on being very tired. Can I close this question?
@Melrache, you can close the question by ticking that checkmark and mark this as answered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.