facilityregistry / fred-api

Facility Registry API Documentation Website
11 stars 4 forks source link

Is the code field in the json object a string or an integer ? #65

Open turtlean opened 10 years ago

turtlean commented 10 years ago

I'm working on the implementation of delete_facility in resource map by using the fred api. I've got a question about the "Delete a facility" section in the api. I don't know which class the code field of the json object that must be returned belongs to.

Status: 200 ok. {code: 200, id:'...', message: 'Resource deleted'} So it makes me think that the code field is numeric.

Anyway if the resource for id is not found:

Status: 404 Not Found. {code: 404 Not Found, message: 'Resource not found'} So it makes me think that it should be a string.

edjez commented 10 years ago

Hi, thanks. About your question Identifiers and their types and uses are described here: http://facilityregistry.org/#facility-resource

There are many identifiers - ones which are assigned by the users & clients of the systems, which can be of any type. Then there is an internal ID which we gravitated towards a UUID - which is for versioning identity purposes. Note that the link to the facility - the href - may or may not use any of the above - each implementation may take a different approach.

About the comment: Yeah it seems to be a small inconsistency. In general we tried to avoid using response codes to echo back information that was part of the request for starters. Maybe this is something to be cleaned up in a next rev. If anyone recalls a specific discussion about why DELETE echoes back the ID, then pls chime in.

On Dec 17, 2013, at 10:52 AM, turtle-lea notifications@github.com wrote:

I'm working in resource map and I don't know which class the code field's belongs to. For example, when deleting a facility:

Status: 200 ok. {code: 200, id:'...', message: 'Resource deleted'} So it makes me think that the code field is numeric.

Anyway if the resource for id is not found:

Status: 404 Not Found. {code: 404 Not Found, message: 'Resource not found'} So it makes me think that it should be a string.

— Reply to this email directly or view it on GitHub.

turtlean commented 10 years ago

Hi Ed,

My question was about the "code" part of the JSON response. In one case it says:

{code: 200, ...}

In another case it says:

{code: 404 Not Found, ...}

But this last example is not a valid JSON. It would be a valid one if it was {code: "404 Not Found"} (that is, enclosed in a string). The previous JSON had {code: 200} (a number). So which one should it be, a string or a number?

Thanks, Lea