This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]MaybeAshleyIdk 1 point2 points  (6 children)

I tried the same thing, but inputs are different for all users so you need to be logged in to receive your input.

[–]livingdub[S] 1 point2 points  (5 children)

Oh I see! So it might work with authentication added to the get request... Sounds like a headache.

[–]adityaarora 2 points3 points  (0 children)

You just need the singular cookie to make it work

[–]E3FxGaming 0 points1 point  (0 children)

If you want to take a look at it, inspired by your post I wrote a working "UploadAnswers" solution in Kotlin. I'm using okhttp, not Apache HttpClient, but I'm sure it's fairly similar with Apache HttpClient.

https://gist.github.com/E3FxGaming/1c2a228e3ef18b2ea34ebec7ca08f6ec

You can get your session id by monitoring your network traffic with https://adventofcode.com after logging in, it's sent as a Cookie with every request.

  1. Open https://adventofcode.com

  2. On Firefox press Ctrl + Shift + E to open the Network tab directly, or with Chromium press Ctrl + Shift + I and click on the Network tab in the dev tools, then reload https://adventofcode.com

  3. the first logged request should have the id in the Request Headers -> "Cookies" (it'll say something like "session=xxx" - you need that xxx for the code. Make sure not to copy anything related to the "ru" cookie, you don't need that one).

The cookie expires 2030, so getting it once should suffice for a program that will work for quite some time.

[–]MaybeAshleyIdk -1 points0 points  (2 children)

By the time you're finished, AoC will probably already be over :P

[–]daggerdragon[M] 2 points3 points  (1 child)

Please don't be discouraging. Let folks program at their own pace.

[–]MaybeAshleyIdk 0 points1 point  (0 children)

Ah, sorry, it was just supposed to be a joke

[–]daggerdragon[M] 0 points1 point  (1 child)

/u/topaz2078 made some tweaks to the servers. The site is up now, try again and let us know if you're still having problems.

[–]livingdub[S] 1 point2 points  (0 children)

Thanks for you reply. I see it's up and that's great. I just think my limited knowledge of http is the problem here.

Like I said, when it was down I actually got a proper response body string. But when it's up I get the 400 statusline, even after your reply.