Escaping curl command in Windows

前端 未结 3 1300
走了就别回头了
走了就别回头了 2021-01-13 13:46

I\'m trying to run a curl command from the command line in Windows, but for the life of me I can\'t figure out how I\'m supposed to escape it.

I\'m exec

相关标签:
3条回答
  • 2021-01-13 14:00

    Quoting is hell. By "Windows Command Line and your prompt I presume you mean cmd.com ?. That doest quote the same as linux shells.

    For this simplistic experiment I recommend going for 2 kinds of quotes to avoid escaping But even then its unlikely to work

    curl --anyauth --user user:password -X POST -d "{'rest-api':{'name':'BizSimDebug3'}}" -H "Content-type: application/xml" http://localhost:8002/v1/rest-apis
    

    Better luck might be had by going with a unix-like shell such as running cygwin (http://www.cygwin.com/) or maybe xmlsh (www.xmlsh.org) which escape like linux does.

    You really are going to have a nightmare running anything complex through the windows command line natively.

    -David

    0 讨论(0)
  • 2021-01-13 14:06

    This works in Windows:

     
    curl -i -X POST -H "Content-Type: application/json" -d "{\"Field1\": 123, \"Field2\": 456 }" "http://localhost:8080"
     
    0 讨论(0)
  • 2021-01-13 14:18

    The XDMP-DOCROOTTEXT error indicates the server is trying to parse the payload as XML and failing.

    The Content-Type header is telling the server that you're sending XML, but the payload is JSON.

    Try changing the Content-Type header to application/json

    0 讨论(0)
提交回复
热议问题