curl (3) and “URL using bad/illegal format or missing URL”

后端 未结 3 967
庸人自扰
庸人自扰 2021-01-28 16:14

I have been trying to figure out why i cant run this piece of code for a while now.

curl -X POST \'

        
相关标签:
3条回答
  • 2021-01-28 16:33

    try this:

    curl -X POST 'http://tp-api.herokuapp.com/beacons/' -H 'Content-Type: application/json' -d '{"beacons": [{"id": "a", "location": [10, 0]}, {"id": "b", "location": [0, 10]}, {"id": "c", "location": [0, 0]} ]}'
    

    the 'a' tag doesn't make sense

    0 讨论(0)
  • 2021-01-28 16:35

    I checked the URL 'tp-api-server.herokuapp.com/beacons' , and it doesn't have any key as "id" which you have mentioned in your post request.

    Try this , {"beacons": {"a": [10, 0], "b": [ 0, 10], "c": [ 0, 0] }}

    0 讨论(0)
  • 2021-01-28 16:52

    You can't just put an HTML anchor link in the command. Remove this and put the URL at the end of the command:

    curl -X POST
    -H 'Content-Type: application/json'
    -d '{"beacons": [{"id": "a", "location": [10, 0]}, {"id": "b", "location": [0, 10]}, {"id": "c", "location": [0, 0]} ]}'
    http://tp-api.herokuapp.com/beacons/
    

    One liner:

    curl -X POST -H 'Content-Type: application/json' -d '{"beacons": [{"id": "a", "location": [10, 0]}, {"id": "b", "location": [0, 10]}, {"id": "c", "location": [0, 0]} ]}' http://tp-api.herokuapp.com/beacons/
    
    0 讨论(0)
提交回复
热议问题