For a Order Management Application, i need to design RESTful APIs which works with JSON.
I would prefer my APIs are like these, whereby request/response contains JSON:
Order Search API
API: /orders/search
{
custname: "john",
orderdate: "10-jun-2013"
}
Response:
{
orders:[
{
orderid:234234,
orderstatus: NEW,
customer: "john"
}
]
}
Order Update API
API: /orders/343455
Request Body:
{
orderstatus: "DELIVERED",
recepient: "joe"
}
Response:
{
status: ERROR,
message: "Order does not exist"
}
Question:
1. How can i send JSON in a GET request (as in Order Search API).
2. I am even thinking of making every request a POST request, with JSON request in body, suggesting what the operation is - but then would this still be REST (perhaps 'RESTful Web-Service' or 'REST like Service' )?
3. I think its important for me to send JSON in most requests, that way my APIs implementations do not undergo much changes, just becz i added removed attribs to JSON message.
4. Are there any examples of how other people have done it, especially returning error messages.
Any thoughts?