-1

Hiiii,

I am developing a small app using Restlet 2.0 API..

I want just to know how to create a URI which accepts more than one parameter for insert query.

Ex:

router.attach("/{patient}/insertpatient", insertpatient);

I want to insert all the info about the patient using POST.

Or Search by ID and address for instance using GET.

thanks,

Sam DeHaan
  • 10,246
  • 2
  • 40
  • 48

1 Answers1

1

For the "insert patient" operation, I'd suggest something like a POST to /patients (if the server generates the patient ID) or a PUT to /patients/{patient-id} (if the client generates the patient ID). Either way, the body of the message would contain all of the input data needed to create a new patient entity. Two simple options for serializing the data would be as a URL-encoded form or as JSON.

Lookup by by ID could be a simple as a GET on /patients/{patient-id}. Lookup by address could also be a GET, possibly using a URL-encoded query parameter. For example, you could fetch the patient at address "123 Main Street, apt 4, Anytown, USA, 98765" with a GET on /patients?addr=%20Main%20Street%2C%20apt%204%2C%20Anytown%2C%20USA%2C%2098765

Andy Dennie
  • 6,012
  • 2
  • 32
  • 51
  • so can you provide me with a code example for the PUT method for both client and server because I already did it but an error pops up indicating that the media type is not supported.. – dalia sobhi Apr 18 '12 at 16:26
  • as for the put method thank God it's resolved, but can you provide me with sample code of how to fetch patient using bith ID and address.. – dalia sobhi Apr 18 '12 at 19:03
  • sorry, I can't right now, as I'm away and won't be back at my computer for a few days. Perhaps someone else who is following this question could assist? – Andy Dennie Apr 18 '12 at 20:20