I'm trying to create a Google Classroom CourseWork via their API. Specifically, this call: https://developers.google.com/classroom/reference/rest/v1/courses.courseWork/create
I'm using the Google Ruby API gem to do so.
Every time I try to create a CourseWork with scheduledTime, I get back an Internal Server Error.
Example request:
Sending HTTP post https://classroom.googleapis.com/v1/courses/5022964882/courseWork?
{"description":null,"dueDate":null,"dueTime":null,"materials":[{"link":{"url":"https://google-c.gc.localhost.mine.com:3000/scores/view/f78df89b0f92be257f004501b7c4958216f2167b"}}],"maxPoints":null,"scheduledTime":{"seconds":1601913540000,"nanos":0},"state":"DRAFT","title":"test2","workType":"ASSIGNMENT"}
And response:
#<HTTP::Message:0x00007f7fb2fdeee8 @http_header=#<HTTP::Message::Headers:0x00007f7fb2fdeec0 @http_version="1.1", @body_size=0, @chunked=false, @request_method="POST", @request_uri=#<Addressable::URI:0x3fbfd97efd78 URI:https://classroom.googleapis.com/v1/courses/5022964882/courseWork?>, @request_query=nil, @request_absolute_uri=nil, @status_code=500, @reason_phrase="Internal Server Error", @body_type=nil, @body_charset=nil, @body_date=nil, @body_encoding=#<Encoding:UTF-8>, @is_request=false, @header_item=[["Vary", "Origin"], ["Vary", "X-Origin"], ["Vary", "Referer"], ["Content-Type", "application/json; charset=UTF-8"], ["Content-Encoding", "gzip"], ["Date", "Mon, 26 Oct 2020 15:36:14 GMT"], ["Server", "ESF"], ["Cache-Control", "private"], ["X-XSS-Protection", "0"], ["X-Frame-Options", "SAMEORIGIN"], ["X-Content-Type-Options", "nosniff"], ["Alt-Svc", "h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""], ["Transfer-Encoding", "chunked"]], @dumped=false>, @peer_cert=#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name CN=upload.video.google.com,O=Google LLC,L=Mountain View,ST=California,C=US>, issuer=#<OpenSSL::X509::Name CN=GTS CA 1O1,O=Google Trust Services,C=US>, serial=#<OpenSSL::BN:0x00007f7fb2fce818>, not_before=2020-10-06 06:40:00 UTC, not_after=2020-12-29 06:40:00 UTC>, @http_body=#<HTTP::Message::Body:0x00007f7fb2fdee48 @body="{\n \"error\": {\n \"code\": 500,\n \"message\": \"Internal error encountered.\",\n \"errors\": [\n {\n \"message\": \"Internal error encountered.\",\n \"domain\": \"global\",\n \"reason\": \"backendError\"\n }\n ],\n \"status\": \"INTERNAL\"\n }\n}\n", @size=0, @positions=nil, @chunk_size=nil>, @previous=nil>
It only seems to be scheduledTime that has this problem - if I drop that field from the request, everything else creates just fine.
I was passing the Date in from JS to Ruby, and needed to divide the epoch timestamp by 1000 to get them on the same page. I don't think returning a 500 is the right response for my accidentally huge date and hopefully Google adds some additional handling.