Hi All,
I am trying to call the Spring REST application's POST call with the below curl commands.
>curl -v --request POST --data @postdata.txt
http://localhost:8080/spring-rest-service/contact.json --header "Content-Type:application/json"
>curl -v --request POST --data '{"id":1,"firstName":"John","lastName":"Santosh"}' --header "Content-Type: application/json"
http://localhost:8080/spring-rest-service/contact.json
Both commands are exactly same except specifying the json data in file for first command. 1st command is working fine but later is not!!! Later command is giving the below error:
* Adding handle: conn: 0xccae58
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0xccae58) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 8080 (#0)
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /spring-rest-service/contact.json HTTP/1.1
> User-Agent: curl/7.32.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json
> Content-Length: 40
>
* upload completely sent off: 40 out of 40 bytes
< HTTP/1.1 400 Bad Request
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Content-Type: text/html;charset=utf-8
< Content-Length: 968
< Date: Sun, 08 Sep 2013 14:34:49 GMT
< Connection: close
<
<html><head><title>Apache Tomcat/6.0.36 - Error report</title><style><!--H1 {font-family:T
ahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-fami
ly:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-
family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:T
ahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,
sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color :
black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - </h1><HR size="
1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>de
scription</b> <u>The request sent by the client was syntactically incorrect.</u></p><HR si
ze="1" noshade="noshade"><h3>Apache Tomcat/6.0.36</h3></body></html>* Closing connection 0
The data in the postdta.txt is as below:
{"id":1,"firstName":"John","lastName":"Santosh1"}
Please let me know if you can help.
Thanks.