Markus Grigoleit
31 posts
Registered:
04 Jun 2019
Answered
10 Jan 2020
Link to this post
So the other day i tried to read in a jsonarray directly. Normally we would define some class and use it like this:
@RestMethod (address="/foo", requestMethod="post", parameterClassName="class.name.of.foo", response="return").
METHOD PUBLIC VOID restMethod (foo AS class.name.of.foo):
TEMP-TABLE ttTable:READ-JSON("JsonArray":U, foo:bar, "EMPTY":U).
END METHOD.
Its kinda annoying to define two files. So cant we just skip the middleman like this:
@RestMethod (address="/foo", requestMethod="post", parameterClassName="Progress.Json.ObjectModel.JsonArray", response="return").
METHOD PUBLIC VOID restMethod (foo AS Progress.Json.ObjectModel.JsonArray):
TEMP-TABLE ttTable:READ-JSON("JsonArray":U, foo, "EMPTY":U).
END METHOD.
This is the result:
"title": "An application error has occurred (Consultingwerk.OERA.RestResource.UnsupporteRequestEntityException)",
"error": "Consultingwerk.OERA.RestResource.UnsupporteRequestEntityException",
"message": "Invalid request entity type: Progress.Json.ObjectModel.JsonArray",