< was unexpected at this time. from curl command line when posting input data as an xml to rest service < was unexpected at this time. from curl command line when posting input data as an xml to rest service json json

< was unexpected at this time. from curl command line when posting input data as an xml to rest service


Actually, I don't know what is the case,but I got an error said < is unexpected this timewhen I tried the following command (on windows):

curl -u admin:password -XPOST -H 'Content-type: text/xml' -d '<namespace><prefix>newWorkspace</prefix><uri>http://geoserver.org</uri></namespace>' http://localhost:8080/geoserver/rest/namespaces

Then I changed the single quote into double quotes and it worked.


Redirection symbols can be escaped by "

Try using

curl -d "{\"input1\": \""<xml></xml>"\", \"input2\": \""<xml></xml>"\"}"  -i -X POST -H "Content-Type:application/json"  http://localhost/rtygies/Service1.svc/rest/receivedata1


I had no luck with double-quotes, however escaping < and > with ^ worked for me.

So your curl becomes..

curl -d "{\"input1\": \"^<xml^>^</xml^>\", \"input2\": \"^<xml^>^</xml^>\"}"  -i -X POST -H "Content-Type:application/json"  http://localhost/rtygies/Service1.svc/rest/receivedata1