REST and read-only properties

Another quick REST / HttpAPI question.

It seems that, when defining classes derived from TROComplexType which are used as parameters in my REST methods, any read-only properties are excluded.

As an example, say I’m defining a “customer” class which is used both as a parameter to a PUT method to add a customer and also as a result from a GET method to retrieve a customer.

Now not all fields in this class are “bi-directional”. Some should only be included in the result from the GET method whilst others should only be included in the parameter to the PUT method.

I assumed that this could be dictated by whether the published properties of the class had read/write methods, so any read-only properties would only appear when used as a result and any write-only properties only when used as a parameter.

This appears not to work and, if I remove the write method from a property, rendering it read-only, it disappears completely.

Is this by design? Is there any way I can engineer this type of solution or do I have to use two different classes?

Hi,

You can have 2 classes in this case.

properties should be r/w otherwise we can’t initialize class correctly. in case of Code-First, we access to properties via RTTI.