How to post XML data with cURL using cmd in window

2019-06-24 00:30发布

问题:

I am trying to post some xml data using curl on command line. Particularly I m trying to run the following command to connect to a billing service provider:

curl https://core.spreedly.com/v1/gateways.xml \
    -u 'secretKey' \
    -H 'Content-Type: application/xml' \
    -d '<gateway><gateway_type>test</gateway_type></gateway>'

However I m keep getting the following error:

< was unexpected at this time.

How should I type my xml data?

回答1:

Redirection symbols can be escaped by placing those within double quotes ".

Instead of saying

'<gateway><gateway_type>test</gateway_type></gateway>'

you need to say

"<gateway><gateway_type>test</gateway_type></gateway>"


标签: xml curl cmd