question

prathapsaireddy avatar image
prathapsaireddy asked prathapsaireddy answered

How to handle 429 error while using web hooks

i was getting 429 error many a times while we are using web hooks for Api triggers. Is there any way that this error can be handled. ( I am aware of clover's Api rate limits) But cannot handle even them. Is there any way that frequent web hook triggering can be halted. As it starts triggering all the time even in the middle of the code
Webhooks
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lee Tickett avatar image
Lee Tickett answered
If I understand correctly, it sounds like you are suggesting each time a webhook fires your web app is making an API call?
Could you give a little more information on what you are doing and why?
Could you perhaps instead queue (and potentially combine) the requests?
Alternatively, just employ the normal measure of handling the 429 response by waiting then trying again?
Thanks
L
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

prathapsaireddy avatar image
prathapsaireddy answered
@ Lee Tickett
Hey Lee Tickett, Thanks for responding. I was trying to make an application on applying discounts and here comes the problem when i was trying to make it work correctly. Let me explain you briefly .
Step 1 : By GET order Api, fetch all the line items present in an order and differentiate accordingly whether the items has been discounted earlier or not.
Step 2 : After that, check if the items are available for discounts(which can be checked through our personal database) and then store the line item which needs to be discounted and the discounted price for that particular line item.
Step 3 : When applying discounts through POST discounts Api and iterating the loop for each line item, we were getting 429 requests problem even though we were trying to halt the loop for 1 second( testing the worst case scenario) by making it sleep.
Note : The 429 error is X-RateLimit-tokenConcurrentLimit : only 5 concurrent requests are allowed.
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lee Tickett avatar image
Lee Tickett answered
Any ideas on the volumes? I definitely think the queuing technique may be best if you're finding often more than 5 hooks are triggering your API call simultaneously.
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

prathapsaireddy avatar image
prathapsaireddy answered
@Lee Tickett hey would you please suggest one queuing technique in which Api calls can be handled effectively. and btw thanks for the support you've given so far.
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community