Can a link in a hal/json element return a 404? -


im implementing hal/json api.

the root object (soldier) has related object (sword), mapped under /soldier/{object_id}/sword

{   "id": 12345,   "name": "sir smokealot",   "_links": {     "self": {       "href": "http://soldier.local:8080/soldier/12345"     },     "sword": {       "href": "http://soldier.local:8080/soldier/12345/sword"     }   } } 

but not every soldier has sword. imagine poor soldier without sword.

  1. if retrieve soldier-object, should link /soldier/{object_id}/sword appear in _links-array?

  2. and if should, link? empty object or 404? allowed hal/json rfc have links in _links-array lead 404?

i don't ask how solve this, want know whats right.

ideally, think wouldn't publish link if soldier doesn't have sword (if it's not expensive calculate). returning httpstatuscode 404 leaves no room interpretation in opinion, unlike "empty object" (whatever be). don't see issues link leading 404, proposed draft specification might interpreted otherwise (rfc 5988 seems have info on this).

i don't think you'll find strict, enforced rules in area of restful hal, more guidelines, there's right or wrong, black or white, more shades of grey - find out works , establish clear contract clients.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -