We are trying to build some automation to recover from REST Service notification failures.
After 3 retries, Kobo will send an email notification with the list of failed notifications.
This list includes the error and response code, as well as some ID, which we were hoping to be able to use to fetch individual failed submissions via API.
Unfortunately it looks like this unique id is not the form submission id, and we therefore cannot use this to retrieve the submission. It seems to be an id specific to the REST Service invocation (?).
Can someone explain what this id is appearing in the REST Service failure email notifications, and how this could help us identify the undelivered submissions?
Hi @yjouanique, the UID you are referring to is the hook log UID that looks like
hlGKQir5k8Ef2SMs7FNo7eH (starting with
hl). You can associate this with the submission by the following:
- Find the UID of your REST Service at
https://[kf_url]/api/v2/assets/[asset_uid]/hooks.json, for example:
- Make a request to
https://[kf_url]/api/v2/assets/[asset_uid]/hooks/[hook_uid]/logs/[uid from the email].json
You will see the
submission_id in the JSON response that looks something like this:
"message": "HTTPSConnectionPool(host='example.com', port=443): Max retries exceeded with url: /example (Caused by SSLError(SSLError(\"bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])\")))",
Great, this works very well! Many thanks!
This actually got me thinking: it looks like rather than manually copy-pasting the hook log id from the mail notification to a sheet, and then doing my own processing, I can probably just query the failed hooks from the API and just trigger the retry!
@yjouanique that’s correct
Actually after playing a bit with the API I felt that it wouldn’t let me do quite what I wanted, so I’ve created this new feature request: Hooks API improvements: filter and force retry · Issue #3536 · kobotoolbox/kpi · GitHub
I’ve worked around it, but it’s a little cumbersome right now, I hope these improvements can be considered…
Thank you for the feature request