Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

when i post a raw string as an input to JSON REST Service call it is executing ex:

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

But when i am posting as an xml as input it is giveng error as below:

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

Error: < was unexpected at this time

I am using curl in windows.

can any one say how to post xml as a string input to Rest service in JSON format from curl

like image 601
Ashish Patha Avatar asked Dec 05 '22 11:12

Ashish Patha


1 Answers

Actually, I don't know what is the case, but I got an error said < is unexpected this time when 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.

like image 168
cathy Avatar answered Mar 09 '23 01:03

cathy