We extensively use the Send API Data action to submit form responses via API to our platform.
We have the logging add-on enabled, which is great at logging what happened but you have to check the logs if you know there was an issue.
We have had situations where a form was submitted and our API call failed, but we didn't know.
Is there anyway of setting up an alert via email if the API response was anything other than a 200 OK message? Or, if the response was anything other than a 200, could we display a failure message to the end user so they know it was unsuccessful?
Thanks
Gavin
It's amazing that this was left unanswered Gavin. You would think a notification styled error handling would be a default action for API calls. I did email the Formidable team about this question and they supplied a partial answer.
They referenced this hook: https://formidableforms.com/knowledgebase/frm_api_post_response/
I attempted to utilize it to fire a wp_mail() function on the else condition, but the hook does not appear to fire when in my functions.php. I'm wondering if you had been able to solve your original inquiry from 5 months ago?
Thanks, Steve
It would be helpful to know how you determined add_action("frmapi_post_response", "your-function", 10, 3) is not firing after you send an API request. Are you adding a break point to examine the values of the parameters $response, $entry, and $form_action? Please share how you performed the diagnostics?
Hey Steven. I found the same KB article and managed to use the examples to update a field in the record with the API status response.
add_action( 'frmapi_post_response', 'frm_save_api_response', 10, 3 ); function frm_save_api_response( $response, $entry, $form_action ) { $status = wp_remote_retrieve_response_code( $response ); FrmProEntryMeta::update_single_field( array( 'entry_id' => $entry->id, 'field_id' => 11, 'value' => $status, ) ); }
Then, when field_id is anything other then a '200' I give the user an error and also send a Slack notification to our support team to investigate further.
This has been working well so far.
Regards,
Gavin
Hey Steven. I found the same KB article and managed to use the examples to update a field in the record with the API status response.
add_action( 'frmapi_post_response', 'frm_save_api_response', 10, 3 ); function frm_save_api_response( $response, $entry, $form_action ) { $status = wp_remote_retrieve_response_code( $response ); FrmProEntryMeta::update_single_field( array( 'entry_id' => $entry->id, 'field_id' => 11, 'value' => $status, ) ); }
Then, when field_id is anything other then a '200' I give the user an error and also send a Slack notification to our support team to investigate further.
This has been working well so far.
Regards,
Gavin
Please login or Register to submit your answer