Windows: curl with json data on the command line

后端 未结 2 1500
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 17:20

I am running the following command in Windows prompt:

curl -XPUT http://127.0.0.1:9200/test-index/test-type/_mapping?pretty=true -d \'{\"test-type\": {\"prop         


        
相关标签:
2条回答
  • 2020-12-06 17:40

    Windows's cmd doesn't support strings with single quotes. Use " and escape the inner ones with \".

    0 讨论(0)
  • 2020-12-06 17:40

    "I searched for solutions and found alternatives such as put json data in files, but I cannot use it for some reasons"

    This should work, with hello.json in temp. The @ is requried.

    c:\temp>curl -v -X PUT  \ 
                 --data "@hello.json"  \
                 -H "Content-Type:application/json"  \
                 http://localhost:8080/api/myresource
    
    0 讨论(0)
提交回复
热议问题