Webhook Messages gives dates as unix timestamps  Topic is solved

Discussions relating to the REST API of Jiwa 7.

Webhook Messages gives dates as unix timestamps

Postby Joe.Thorpe » Fri Jul 01, 2022 8:33 pm

Apologies for posting again about Webhooks :)

Webhook Messages provide dates as WCF Dates:
"InvoiceInitDate": "\\/Date(1656574620530-0000)\\/",

Power Automate expects ISO8061, as do many C# tools to be honest. Both REST API responses and XML export from JIWA use ISO8061, so i'm curious why Webhooks don't.

I can see where it's configured in RESTAPIPlugin.Configure():
ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.DateHandler.ISO8601;

I've just added it to BusinesLogicPlugin.Setup(), which is working.

Cheers,
Joe
Joe.Thorpe
Occasional Contributor
Occasional Contributor
 
Posts: 19
Joined: Fri Jun 11, 2021 1:57 pm

Re: Webhook Messages gives dates as unix timestamps

Postby SBarnes » Sat Jul 02, 2022 10:54 am

Hi Joe,

The reason that the web hooks are not using that date format is as you rightly determined it is not set in the business logic work space i.e. in the client, the way the web hooks work is that on certain events the business logic in the client or any application it serialises itself and then makes a call to the ServiceStack extension method toJson that actually turns the object into Json which is why your change is working.

This is then posted to an endpoint on the REST API itself that does the sending and logs things to the appropriate tables namely SY_WebhookMessage and SYWebHookMessageResponse and handles all the possibly necessary retries etc.

My only other comment is you are best not to actually change the REST api plugin, as this could become a problem during upgrades but rather you should create a new plugin and add references to the appropriate ServiceStack libraries from Jiwa's program directory and to avoid needing to add all the business logic references that the REST API has to keep them in sync simply just put the line inside the set up call for the Application plugin instead as it only needs to be called the once any way.

By doing this you'll make future upgrades easier and not need to apply any custom changes to the new version.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhook Messages gives dates as unix timestamps  Topic is solved

Postby Mike.Sheen » Mon Jul 04, 2022 10:59 am

Logged DEV-9385 to make this standard.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Webhook Messages gives dates as unix timestamps

Postby SBarnes » Mon Jul 04, 2022 11:10 am

It's worth noting mentioned here https://docs.servicestack.net/customize ... n-settings that according to the documentation this can be overridden on the query string for all services.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhook Messages gives dates as unix timestamps

Postby Mike.Sheen » Mon Jul 04, 2022 11:24 am

SBarnes wrote:It's worth noting mentioned here https://docs.servicestack.net/customize ... n-settings that according to the documentation this can be overridden on the query string for all services.


Unfortunately I don't think that will help in this case as there is no query string to modify for the webhook origin. But yes - it is worth noting that for normal requests to the API there are a bunch of overrides possible via the query string parameters.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Webhook Messages gives dates as unix timestamps

Postby SBarnes » Mon Jul 04, 2022 11:28 am

I was mentioning it for service calls in general and not web hooks and more about whether or not you want properties of default values to be included which is one that customers have asked about as well as the other options mentioned but yes you are right I should have been clearer with the comment offered.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Webhook Messages gives dates as unix timestamps

Postby Joe.Thorpe » Tue Jul 05, 2022 1:12 pm

SBarnes wrote:Hi Joe,

The reason that the web hooks are not using that date format is as you rightly determined it is not set in the business logic work space i.e. in the client, the way the web hooks work is that on certain events the business logic in the client or any application it serialises itself and then makes a call to the ServiceStack extension method toJson that actually turns the object into Json which is why your change is working.

This is then posted to an endpoint on the REST API itself that does the sending and logs things to the appropriate tables namely SY_WebhookMessage and SYWebHookMessageResponse and handles all the possibly necessary retries etc.

My only other comment is you are best not to actually change the REST api plugin, as this could become a problem during upgrades but rather you should create a new plugin and add references to the appropriate ServiceStack libraries from Jiwa's program directory and to avoid needing to add all the business logic references that the REST API has to keep them in sync simply just put the line inside the set up call for the Application plugin instead as it only needs to be called the once any way.

By doing this you'll make future upgrades easier and not need to apply any custom changes to the new version.


Thanks Stuart, it didn't occur to me that it could be done from a separate plugin, i'll give that a shot. Thanks for your help!
Joe.Thorpe
Occasional Contributor
Occasional Contributor
 
Posts: 19
Joined: Fri Jun 11, 2021 1:57 pm

Re: Webhook Messages gives dates as unix timestamps

Postby Joe.Thorpe » Tue Jul 05, 2022 1:12 pm

Mike.Sheen wrote:Logged DEV-9385 to make this standard.


Great! thanks Mike
Joe.Thorpe
Occasional Contributor
Occasional Contributor
 
Posts: 19
Joined: Fri Jun 11, 2021 1:57 pm


Return to REST API

Who is online

Users browsing this forum: No registered users and 2 guests