在Windows中转义curl命令

Bla*_*ppo 4 windows curl marklogic

我试图curl从Windows命令行运行一个命令,但对于我的生活,我无法弄清楚我应该如何逃避它.

我正在执行这个:

C:\WINDOWS\system32>curl --anyauth --user user:password -X POST -d "{\"rest-api\":{\"name\":\"BizSimDebug3\"}}" -H "Content-type: application/xml" http://localhost:8002/v1/rest-apis
Run Code Online (Sandbox Code Playgroud)

我得到了这个:

<rapi:error xmlns:rapi="http://marklogic.com/rest-api">
  <rapi:status-code>400</rapi:status-code>
  <rapi:status>Bad Request</rapi:status>
  <rapi:message-code>RESTAPI-INVALIDCONTENT</rapi:message-code>
  <rapi:message>Your bootstrap payload caused the server to throw an error.  Underlying error message: XDMP-DOCROOTTEXT: xdmp:get-request-body() -- Invalid root text "{&amp;quot;rest-api&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;BizSimDebug3&amp;quot;}}" at  line 1</rapi:message>
</rapi:error>
Run Code Online (Sandbox Code Playgroud)

还有什么我需要做的事情来逃避-d标志中的内部引号吗?还是我完全忽略了真正的问题?

小智 7

这适用于Windows:

 
curl -i -X POST -H "Content-Type: application/json" -d "{\"Field1\": 123, \"Field2\": 456 }" "http://localhost:8080"
 


ehe*_*num 2

XDMP-DOCROOTTEXT错误表明服务器正在尝试解析有效​​负载,XML但失败。

Content-Type头告诉服务器您正在发送XML,但有效负载是JSON

尝试将Content-Type标题更改为application/json