Ignore attributes in REST api

Ignore attributes in REST api

  

Is there a way in Outsystems to set an attribute to be ignored in the REST api?

Currently, our public facing api structure is mapped to an internal structure. Anything private is only added to the internal structure.

in .NET we would be able to ignore the json attribute and therefore only have the need to support one structure.

Thanks

Kieran Morten wrote:

Is there a way in Outsystems to set an attribute to be ignored in the REST api?

Currently, our public facing api structure is mapped to an internal structure. Anything private is only added to the internal structure.

in .NET we would be able to ignore the json attribute and therefore only have the need to support one structure.

Thanks

Hi Kieran,

In Outsystems you have OnBeforeRequest event, there you can customize the request before it submit.

 Thanks 

Balu


Balu wrote:

Kieran Morten wrote:

Is there a way in Outsystems to set an attribute to be ignored in the REST api?

Currently, our public facing api structure is mapped to an internal structure. Anything private is only added to the internal structure.

in .NET we would be able to ignore the json attribute and therefore only have the need to support one structure.

Thanks

Hi Kieran,

In Outsystems you have OnBeforeRequest event, there you can customize the request before it submit.

 Thanks 

Balu


Hi Balu,

I don’t think this is a practical solution, not when you have a complex structure plus it feels hacky.
I think Kieran means flagging an attribute as serializable or not serializable. I am not sure what serializer OutSystems is using, but this will be the equivalent of the [JsonIgnore] in JOSN.Net or [XmlIgnore] in .NET.

OutSystems provides a JSON properties configuration for attributes but with only 1 property, [Name in JSON].  You’d expect to find more decorators here including being able to exclude an attribute from being serialized.

Thanks
Gerald

Hi Kieran,

Any JSON Attribute not present in the Structure defined for the Consume REST API is automatically ignored by OutSystems. So just remove the Attributes you're not interested in.

EDIT: On 2n reading I think you mean you want to Expose a REST API, right? In that case, copy the Structure and remove any of the "private" Attributes. In the code, you can simply use an Assign to fill the 2nd, public facing, Structure.

I'm not sure if I've been clear. We currently use 2 structures (one public facing, one internal) and there is an overhead in doing so that I want removing.

I want one structure that we expose as part of our external api.

In .NET, we can set the JSON attribute to "ignore" on certain attributes. This means that they are not publicly exposed but can be used internally. It can be done in .NET and we are on the .NET stack so I'm after a way in Outsystems as to expose this behaviour.

Currently I have a structure that is public, with another structure that the public one maps to with additional properties that are used internally.


Solution

Hi Kieran,

There's no equivalent of the "ignore" property in OutSystems. Having two Structures like you already have is the only solution I can think of. However, it might be a good idea to have such an "ignore" or "private" or whatever property for a Structure used in a REST API, so I'd encourage you to create an Idea for it (if there isn't one already).

Solution

Hi,
There has been created a similiar idea for this question on https://www.outsystems.com/ideas/5642/hide-attribute-of-structure-in-webservice-interface