How to get latest changes?  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

How to get latest changes?

Postby minhhieu106 » Thu Mar 29, 2018 3:37 pm

Hi,

I develop a tool to get all the latest changes of data.

e.g. when i changed the customer information this customer will be stored to a table with the customer object type. I only need to get the data from this table for the latest changes.
Are there any api to support it?

Thanks,
minhhieu106
Occasional Contributor
Occasional Contributor
 
Posts: 49
Joined: Thu Mar 29, 2018 3:29 pm
Topics Solved: 0

Re: How to get latest changes?

Postby Mike.Sheen » Thu Mar 29, 2018 4:37 pm

minhhieu106 wrote:Are there any api to support it?


What version of Jiwa are you wanting this for?

If you're using 7.1 then our REST API has a query to get all customers which has changed since a date. You can also create a webhook subscription to send to your own API, or a 3rd party API (like a CRM) system the JSON representing the customer whenever it changes or a new customer is created.

If you're using a version older than 7.1, then a SQL Query can be used to retrieve a list of customers changed since a date.

Mike
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: How to get latest changes?

Postby minhhieu106 » Fri Mar 30, 2018 1:33 am

Hi Mike,

Thank you for your reply.

I am using 7.1. I have created webhooks but still don't know how to use it. :D :D :D
Image

I follow below articles:
https://docs.jiwa.com.au/display/J7UG/Webhooks
https://www.jiwa.com.au/blog/what-s-so- ... rz1KojFKHs

But when i created new debtor but still don't have any record insert into SY_WebhookMessage table.

Do you have any document how to configure it?

Hieu
Attachments
webhooks.PNG
minhhieu106
Occasional Contributor
Occasional Contributor
 
Posts: 49
Joined: Thu Mar 29, 2018 3:29 pm
Topics Solved: 0

Re: How to get latest changes?

Postby Mike.Sheen » Fri Mar 30, 2018 11:44 am

I'm assuming you ran the SQL Script which is on the documents tab of the plugin? If not, you will need to do that.

The only other configuration you need is to set is the system setting for the webhooks plugin, HostURL. This needs to be set to your REST API URL.
That was missing from the documentation - but I've now added that step to the Installation section of the document - thanks!.

Mike
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: How to get latest changes?

Postby minhhieu106 » Fri Mar 30, 2018 12:56 pm

Hi Mike,

Thank you for your update.

I have run SQL script and set REST API URL already.

Image

Image

It is still not working. Are there something wrong on setting?

Thanks,
Attachments
SQL Script.PNG
REST API URL.PNG
minhhieu106
Occasional Contributor
Occasional Contributor
 
Posts: 49
Joined: Thu Mar 29, 2018 3:29 pm
Topics Solved: 0

Re: How to get latest changes?

Postby Mike.Sheen » Fri Mar 30, 2018 1:11 pm

I'm going to assume you have your REST API configured for the URL you supplied to the Webhooks plugin? I see from your screenshots that you have http://localhost/JiwaAPI as your HostURL setting - if you visit http://localhost/JiwaAPI in your web browser, is it running? If it is you should see something like this:

API.PNG
API.PNG (37.21 KiB) Viewed 1023 times
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: How to get latest changes?

Postby Mike.Sheen » Fri Mar 30, 2018 1:20 pm

Can you also look at the results of:

Code: Select all
SELECT * FROM SY_WebhookSubscription


I note you didn't show that in your previous queries you showed (thanks for providing those!)

If you have no rows returned, then it means you need to add a subscription for an event before any changes in Jiwa will result in a webhook being called.

You add subscriptions by performing a POST operation see here.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: How to get latest changes?

Postby minhhieu106 » Fri Mar 30, 2018 3:57 pm

Hi Mike,

Don't have any data from SY_WebhookSubscription table.

You add subscriptions by performing a POST operation see here.


So we only do it via code not support on Jiwa?

Here's my code. It does not work
Image

Could you help to describe below id
Image

Thanks,
Attachments
Add new Subscription.PNG
My Code.PNG
minhhieu106
Occasional Contributor
Occasional Contributor
 
Posts: 49
Joined: Thu Mar 29, 2018 3:29 pm
Topics Solved: 0

Re: How to get latest changes?

Postby Mike.Sheen » Fri Mar 30, 2018 4:13 pm

minhhieu106 wrote:So we only do it via code not support on Jiwa?


Correct - we expect a Subscriber, once created, to add their subscriptions for the events they are interested in.

Your issue is likely because you provide a different subscriber ID in the DTO to the URL you are POSTing to.

Remove the SubscriberID from the JSON altogether - you've POSTed to a URL containing a SubscriberID in the URL, so your JSON does not need a SubscriberID - I actually would have thought that should have returned a 404 for you, but I've never tested POSTing to the /Webhooks/Subscribers/{SubscriberID}/Subscriptions route with a DTO containing a SubscriberID - we already know what the SubscriberID is from the route OR the DTO. I've tested the examples posted in the documentation and using the SubscriberID in the route works for me - so I'd go with that.

Mike
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: How to get latest changes?

Postby minhhieu106 » Fri Mar 30, 2018 4:27 pm

Hi Mike,

I have removed SubscriberID from the JSON. But the same issue. :D :D :D
Image

Code: Select all
   using (var webClient = new System.Net.WebClient())
            {
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(new
                {
                    URL = "http://localhost/iVend",
                    EventName = "debtor.created"
                });
                var responsebody = webClient.UploadString("http://localhost/Jiwaapi/Webhooks/Subscribers/C991854F-D953-46F0-ADFD-C57FF0EF1BD4/Subscriptions/", "POST", json);
            }

SubscriberID = C991854F-D953-46F0-ADFD-C57FF0EF1BD4. This id get from SY_WebhookSubscriber table.

Thanks,
Attachments
Add new Subscription 1.PNG
minhhieu106
Occasional Contributor
Occasional Contributor
 
Posts: 49
Joined: Thu Mar 29, 2018 3:29 pm
Topics Solved: 0

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 21 guests