如何在curl请求的数据中发布URL

Viv*_*hal 37 linux bash curl web-services http-post

我试图发布两个参数,使用curl,pathfileName:

curl --request POST 'http://localhost/Service' --data "path='/xyz/pqr/test/'&fileName='1.doc'"
Run Code Online (Sandbox Code Playgroud)

我知道这有什么不对劲.我必须使用像URLEncode这样的东西.我尝试了许多东西仍然没有运气.

请举例说明如何在curl请求的数据中发布url.

kon*_*box 53

也许您不必包含单引号:

curl --request POST 'http://localhost/Service' --data "path=/xyz/pqr/test/&fileName=1.doc"
Run Code Online (Sandbox Code Playgroud)

更新:阅读curl的手册,你实际上可以用两个--data分隔两个字段:

curl --request POST 'http://localhost/Service' --data "path=/xyz/pqr/test/" --data "fileName=1.doc"
Run Code Online (Sandbox Code Playgroud)

你也可以试试--data-binary:

curl --request POST 'http://localhost/Service' --data-binary "path=/xyz/pqr/test/" --data-binary "fileName=1.doc"
Run Code Online (Sandbox Code Playgroud)

并--data-urlencode:

curl --request POST 'http://localhost/Service' --data-urlencode "path=/xyz/pqr/test/" --data-urlencode "fileName=1.doc"
Run Code Online (Sandbox Code Playgroud)