Frank Q. Frank Q. - 2 months ago 9
HTTP Question

Including extra information in PUT response

Is it ok to return extra information in http

PUT
response such as
createdDateTime
or
lastUpdateTime


E.g. PUT request comes as follows

properties
{
"name": "somename"
"addr": "someaddr"
}


In response along with sending the resource representation I am sending extra information

HTTP OK or CREATED


properties
{
"name": "somename"
"addr": "someaddr"
"lastUpdateTime": "somedatetime"
}


Is this a bad practice ?

Answer

I see no problem with that. If the client needs that information, then the resource will have to include it as a property. The client can POST/PUT without it (NULL), or the server will ignore it anyway (since this is only set server-side), but it will have to reflect it afterwards.

You can always secure your API if you're going to expose it publicly (OAuth, API keys etc).

Comments