Migrate samples to the new API.

Part of a series of PRs which migrates everything away from the `HttpUrlConnection`-based APIs.

Refs #699.