Correctly find .user file for current user. Trim off whitespace when reading from the .user file. Fix error message.
Assign uri to variable and return variable. This makes it easier to debug.
Fix formatting.
Fix formatting and error checking. Check response StatusCode. Make error messages more useful.