I’m making a webservice with JSON going in both directions for all requests, but seem to have run into a catch 22.
A) I try the request as “/questions/1.json?_method=put” but since the _method=put is not in the message body it doesn’t count.
B) I send the params as _method=put&{ “json”: “here” }
The request is recognize as a PUT, but the JSON can’t be interpreted.
C) I send the params as { “_method”:“put”, “json”: “here” }
The request isn’t recognized as a PUT, but the JSON can be parsed (it works using “curl -X PUT …”)
D) I try using GET (with the same approach as A) and it ignores the parameters and the message body.
Where should I attack this beast at?
AJ ONeal
Working Examples:
curl ‘http://www.whatsayye.com/questions.json?callback=jsonp12345’ \
-X “POST” \
-H “Content-Type: application/json” \
-H “Accept: application/json” \
-d “{ "question": { "question": "Created with curl JSON-ically", "url": "curljson" }}”
curl ‘http://www.whatsayye.com/questions/3.json’ \
-X “PUT” \
-H “Content-Type: application/json” \
-H “Accept: application/json” \
-d “{ "question": { "question": "Modified with curl JSON-ically", "url": "jsonrocks" }}”
Failing Examples:
curl ‘http://www.whatsayye.com/questions/3.json’ \
*-X “POST” *
-H “Content-Type: application/json” \
-H “Accept: application/json” \
*-d “_method=put” *
-d “{ "question": { "question": "Modified with curl JSON-ically", "url": "jsonWAYrocks" }}”