POST api – Duplicate posting / Filtering / UUID / Idempotency-Key?

I’ve got myself all confused! :confused:

I have a scenario where I get Leave requests from Breathe HR using a GET api and POST them to Xero. That is working correctly although each time it runs it create a duplicate.

Thinking a filter would work (and it may do if set up correctly!) I added in a GET api to Xero to get all the current leave requests and then have tried some filters such as Xero Leave does not contact Breathe Leave but none of them give the desired outcome.

I only have the start date and end date to work with. I think I need a way of doing “If Breathe Start Date and End Date match the current leave request on Xero, don’t post.” While still posting the new ones.

I then researched and looked into generating a UUID and putting a Idempotency-Key in the POST header which apparently Xero supports to stop dupications. This didn’t work as I believe it was just creating a new UUID each time. I’ve briefly looked into data store but I’m not sure this is the right way to go.

I’m not really sure what to try now or what is the best way to achieve this. Any help would be appreciated!

1 Like

Hi @emma

Please use formatDate() function over both dates and the use does not equal to for filter.

Regards
Msquare Automation - Platinum partner of Make
@Msquare_Automation

1 Like

@Msquare_Automation Thanks for your help. That has kind of worked where the top one (which I am trying to stop) has not gone through but then started posting the other “old” leave requests (only 4 on screenshot as I stopped it running) with the dates we are trying to stop.