Expose API: Validate JSON based on structure with maxlength on attributes
Application Type
Traditional Web, Reactive, Service
Service Studio Version
11.11.12 (Build 47321)
Platform Version

We're currently migrating API's which we've created in ASP.NET MVC before and moving them to OutSystems REST API.

We're building exposed REST API's and thus getting JSON data from other systems with the POST endpoints we provide. The JSON is coming in and we're able to work with the data. So far so good.

Our previous API's would error if we provided maxlengths to properties of objects, we now see that OutSystems doesn't do this although we do specify a MaxLength in the attribute of the structure.

Our structures are over 80 properties with at least 50% textfields and a maxLength. We can't start creating an if-statement for every attribute, so how would we be able to have OutSystems error when one or more of the attributes have a longer length than they should?

Quick example:

We have a POST endpoint PostContact which expects a structure "Contact", will create the contact in the database and then send back the created Contact.

The issue is, when a system sends us (for example) a json with "Type" being longer than 1, we would need it to error. We already specify the Length in the attribute of the structure.

We understand that we could just have an if-statement, but we'd have to do this for ALL our TEXT Attributes and that would take the benefit away of using OutSystems since we used to be able to just use a "data annotation" in ASP.NET MVC. 

Does anyone have the same issue? Is there any way around this that would make this a lot easier?

Thank you in advance for your suggestions!

Hi @Pieter-Jan Hoedt 

Did you ever come up with a way to do this? Facing a similar situation.

@Pieter-Jan Hoedt

I am also interested in if you ever found a solution to this problem.

@Ryan Saunderson I found the only thing that is validated is the DataType of the inputs, nothing else.

@Nicholas Campbell that's unfortunate. With the push towards creating APIs for major pieces of functionality, I'm not feeling comfortable building any public API surfaces on LCAP platforms.

Ideally, we'd be be able to specify an action that triggers on (de)serialization and generates error messages / logs from there.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.