Why is curl truncating this query string?

后端 未结 2 1229
天涯浪人
天涯浪人 2020-11-30 04:12

I\'m sure the answer to this is going to be some painfully obvious character encoding issue...

I\'m using curl on the command line to test some endpoints in a python

相关标签:
2条回答
  • 2020-11-30 05:00

    I think you can try this:

     curl -v -L -d "lat=41.225&lon=-73.1" http://localhost:5000/pulse
    

    by default, this calls POST. If you want to send a GET request

     curl -v -L -G -d "lat=41.225&lon=-73.1" http://localhost:5000/pulse
    

    More...
    and since you're using localhost, if you were to use https, you'd probably want to include -k as an option to ignore certificate errors

    Thanks to Ross for pointing this.

    0 讨论(0)
  • 2020-11-30 05:08

    The answer to the question, "what am I doing wrong," is that the shell sees the ampersand (&) and thinks that's the end of the command (and puts it into the background). You need to quote it, which is why the answers that quoted the string work. You could just as easily run this:

    curl -v -L "http://localhost:5000/pulse?lat=41.225&lon=-73.1"
    
    0 讨论(0)
提交回复
热议问题