Problem with converting a epoch value from RestAPI

0
Hi! I'm extracting some data from a SAP S4/Hana backend. I've created a REST call to get the needed data, but one of the fields is in an unsupported format. Running the requests results in: "A problem occurred parsing attribute 'TimeSheetDate' of object of type 'VerlofUren.JsonObject'. The value was '/Date(1481673600000)/'. This isn't allowed by the schema." I think this can be solved by converting the contents of the object with a microflow, so I wrote this microflow to convert the value to a normal date time (using the CommunenityCommons module): Alas, this doesn't work, and Mendix gives me this error: com.mendix.core.CoreException: com.mendix.modules.microflowengine.MicroflowException: Error parsing JSON. Invalid format: "/Date(1481673600000)/"     at VerlofUren.ACT_CallRestAPI (CallRest : 'Call REST (GET)') Advanced stacktrace:     at com.mendix.basis.component.InternalCore.execute(InternalCore.java:600) Caused by: com.mendix.modules.microflowengine.MicroflowException: Error parsing JSON. Invalid format: "/Date(1481673600000)/"     at VerlofUren.ACT_CallRestAPI (CallRest : 'Call REST (GET)') Advanced stacktrace:     at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:146) This makes me wonder why the 'convert using' function provided by the import mapping is not kicking in. Who can help me with this?   Thank you in advance!   Regards, Bart van den Heuvel   addendum @Eric: Raw output: Formatted tree:  
asked
2 answers
0

Hi,

One possible workaround, albeit not a very nice one is to

1) get the response from rest as a string

2) use a regex replace, or a java action to change

"/Date(1481673600000)/" -> 1481673600000 

(without the quotes).

3) use the import with mapping action to convert the changed string to a mendix object.

-Andrej

 

answered
0

What does your JSON schema look like for the date field? You might need to treat the data as a string in the schema (i.e., wrap the value in quotes) since it looks like the value you're getting back isn't just

1481673600000

like Mendix expects for a date but instead

"/Date(1481673600000)/"

 

answered