8

If I try to access the following from firefox everything works even if I'm not logged in

http://api.stackexchange.com/2.0/users/19068?order=desc&sort=reputation&site=stackoverflow

However

wget http://api.stackexchange.com/2.0/users/19068?order=desc&sort=reputation&site=stackoverflow

gives

Resolving api.stackexchange.com... 64.34.119.12
Connecting to api.stackexchange.com|64.34.119.12|:80... connected.
HTTP request sent, awaiting response... 400 Bad Request
2012-05-08 01:46:49 ERROR 400: Bad Requ

Why do I get an error message?

migrated from meta.stackexchange.com May 8 '12 at 5:51

This question came from our discussion, support, and feature requests site for meta-discussion of the Stack Exchange family of Q&A websites.

15

You'll need to quote that URL.

wget 'http://api.stackexchange.com/2.0...&site=stackoverflow'
     ^                                                      ^

(And note that the payload is gzip-compressed.)

  • 4
    For technical reference, this happens because the & in the URL signifies to the shell to start a new background process and run the code following that. – dunsmoreb May 7 '12 at 22:00
6

The problem is the & characters in the URL. In most shells, foo & bar means "start running foo in the background while running bar in the foreground". Put quotes around the URL to make sure it gets passed as a single parameter to wget.

You must log in to answer this question.