Monday 15 February 2010

httprequest - REST API using GET Params -



httprequest - REST API using GET Params -

say have next server resource:

api.example.com/event/1

which returns arbitrary resource, say:

{ id: 1, details: { type: 'webinar', .... }, attendees: [ { user_id: 1, first_name: 'bob' ... }, ... ] }

it might useful client create request event details of event not list of attendees.

is improve provided 2 separate urls resources , forcefulness 2 separate requests if client wants both resources?

api.example.com/event/{event_id} api.example.com/attendees/{event_id}

or improve offer same 2 endpoints, optionally have first 1 back upwards param toggle attendee listing on or off

api.example.com/event/{event_id}?listattendees={true|false} api.example.com/attendees/{event_id}

where listattendees parameter either have representation homecoming attendee list or not.

is mutual practice allow params alter representation returned specific url?

i'd right way in rest different media-types, or media-type parameters, since people don't utilize custom media-types, utilize phone call zoom protocol. thought have zoom or expand parameter, numeric value, , recursively includes children entities, decreasing parameter until reaches zero.

so, request like:

get api.example.com/event/1

returns plain representation event resource, without embedding anything. request like:

get api.example.com/event/1?zoom=1

would include immediate children of event, in case, atendees. next on that:

get api.example.com/event/1?zoom=2

would include immediate children of event, immediate children of atendees.

to reply question, in rest whole uri atomic identifier, parameters part of uri. can problem if you're using won't interpret uris in same way, old cache servers won't cache uris querystring.

rest httprequest getparameter

No comments:

Post a Comment