Developer forum

Forum » Integration » Parse DateTime from OData endpoint

Parse DateTime from OData endpoint

Anders Ebdrup
Reply

Dear Dynamicweb,

 

I have an issue with importing prices as the OData-endpoint says that the PriceValidTo is an object, which is not handled in Dynamicweb when parsing dates in this method: GetInputToDateTimeFormat.

What is the best way to fix this problem, as I now manually have to adjust "System.Object" to "System.String" in the job-file?

This is the error:

Import job failed: cannot parse '2022-12-31T00:00:00' to a System.DateTime. Table: EcomPrices. Column: PriceValidTo with culture:en-GB The failed input row is:  [Item_No:"00001"], [Sales_Code:"98"], [Minimum_Quantity:"0"], [Unit_Price:"750"], [Ending_Date:"2022-12-31T00:00:00"]

This is from the mapping screen:

 

Best regards, Anders


Replies

 
Rasmus Sanggaard Dynamicweb Employee
Rasmus Sanggaard
Reply

Hi Anders,

Which endpoint are you fetching the data from? An exposed BC SalesPrices page?

It’s not PriceValidTo that is an object, but rather Ending_Date from the source. So, for some reason, the source must be exposing the date as an object—I haven’t seen that before.

The framework is only able to convert String/Datetime to Datetime; we don’t attempt to parse the string that the object is converted to. That could be a potential fix on our end.

Are you able to paste the metadata so we can investigate why Ending_Date is an object?

Additionally, you could try finding the Ending_Date type in the job's source schema XML file and changing it to String.

BR Rasmus Sanggaard

 

 
Anders Ebdrup
Reply

Hi Rasmus,

The endpoint is a NAV 2015, so it is a bit old...

This is the metadata:

And this is from the job-file:

 

Let me know if you need some more information?

 

Best regards, Anders

 
Rasmus Sanggaard Dynamicweb Employee
Rasmus Sanggaard
Reply

Hi Anders,

It looks like NAV 2015 is using Edm.DateTime, whereas BC uses Edm.Date.

Currently, we’re not checking Edm.DateTime, but we should be. We’ll fix this and push a new update to the OData provider (10.8.6).

BR Rasmus Sanggaard

 
Anders Ebdrup
Reply

Hi Rasmus,

 

Has these changes been released yet?

 
Rasmus Sanggaard Dynamicweb Employee
Rasmus Sanggaard
Reply
This post has been marked as an answer

Hi Anders,

Yes, 10.8.6 was released on 12/02.

BR,
Rasmus Sanggaard

Votes for this answer: 1

 

You must be logged in to post in the forum