35
Views
4
Comments
Solved
Converting from OutSystems Date Time to WCF date format
Question

Hello all,


I have the following requirement which I need some help with.

I am consuming a Rest API and Advanced section Date format is set to 2014-01-01T00:00:00Z (ISO) like this: 


For all get methods from this API Dates come like "/Date(1590537600000)/". The fields that return dates in this format are mapped as Date Time in Service Studio. This works perfectly and by default dates end up with format "2020-06-12 17:59:47" so I can directly work with the values.


However the issue comes with the POST methods which require date fields to be in format "/Date(1590537600000)/". Whenever I pass the OutSystems dates to the JSON file they always end up with format "2020-06-12 17:59:47" and the API returns a 400 Bad Request.


My question is: How can I convert this "2020-06-12 17:59:47" OutSystems date into this format: "/Date(1590537600000)/"



Thank you all

mvp_badge
MVP
Rank: #19
Solution

Hi Pedro,

Did you set the date format property of the REST API to WCF? 

Regards,

Daniel

mvp_badge
MVP
Rank: #19

Hi,

What you could try is in your post request use data type string for this datetime attribute.

Create a server action with is function property set to True with input parameter of DateTime and an output parameterof type string.

Add logic to it to convert the datetype.

Then on the POST call pass the result of the conversion on the api method parameter.

Regards,

Daniel


mvp_badge
MVP
Rank: #19
Solution

Hi Pedro,

Did you set the date format property of the REST API to WCF? 

Regards,

Daniel