Browsing the archives for the REST tag.


Interesting REST API Decision

Software

Scenario: a database of images, with a REST API.

Get All is no problem: GET /images/
Get Single is no problem: GET /images/?id=12345
Add New is no problem: POST /images/ (header info)
Update is no problem: PUT /images/ (header info)

But what if I want to say to the API “I know you have an image, and I would like you to take that original image, make a copy, crop the copy to a dimensional size that I will provide to you, and then resize that cropped portion to a final size which I will also provide to you. Oh, and return the ID of the newly-created image.”

I guess technically I’m adding a new resource, but I’m not specifying the pure data for the new resource: I’m giving a set of transformations to apply to an existing resource.

Interesting conundrum. WWRFD?

No Comments

Pressing the Limits of RESTful URI Design

Software, Web

I’m probably missing the boat here somewhere, but:

Say you’re modeling a beauty pageant (no pun intended).  JUDGES fill out BALLOTS on CONTESTANTS.   Each BALLOT has CATEGORIES: for example, “Poise”, “Swimsuit”, “Evening Gown”.

So far so good.  Easy enough.

Let’s say you want to extend the model to include AUDITOR functions.  The business rule is something like: “If a JUDGE returns a BALLOT that is missing entries for one or more CATEGORIES, the ballot is invalid and needs to be returned to the JUDGE.

So you’ve got a conceptual “bucket” that you can identify: bad ballots.  How do you model that RESTfully?

/ballots/bad

/ballots/bad/[id]

/ballots/bad/?category=[category]&judge=[judge]&competitor=[competitor]

??? Maybe this makes more sense the more I look at it.  I was initially thinking I needed to make all sorts of funky prefix URIs like /bycategory/ and /bycompetitor/, but just putting it in the query string makes sense for filtering entities, with no controller involved.

Score another one for thinking out loud via the blog

1 Comment