Since the latter uses hal_json
, you need to do it like this
curl --request GET --user myusername:mypassword --header 'Accept: application/hal+json' \
http://example.com/node/2?_format=hal_json
For more info, see Using other authentication protocols.