Forward form including upload files to a 3rd party via Gravity Form Webhooks plugin

Hi,

Actually, I have a contact form with multiple fields and 2 upload files, that once submitted, send a Form Post to a 3rd party API via the Webhooks plugin, the mapping of the fields is working great. The problem is the 3rd party is waiting for files and it get instead upload urls from file fields, so that is not working.

I read the doc, but I’m not sure how to achieve my goal with Gravity Forms hook, this current scenario is not documented as example.

Any help will be really appreciated.

Thanks.

See if the following helps:

Hi,

I have done something like this:

add_filter( 'gform_webhooks_request_data', 'custom_gform_webhooks_modify_data', 10, 4 );
function custom_gform_webhooks_modify_data( $request_data, $feed, $entry, $form ){
  if ( rgar( $form, 'title' ) !== 'Test' ) {
    return $request_data;
  }

  $cv_file_path = GFFormsModel::get_physical_file_path( rgar( $entry, 6 ) );
  $il_file_path = GFFormsModel::get_physical_file_path( rgar( $entry, 5 ) );

  $request_data['test'] = base64_encode( file_get_contents( $cv_file_path ) );
  $request_data['cv'] = base64_encode( file_get_contents( $cv_file_path ) );
  $request_data['il'] = base64_encode( file_get_contents( $il_file_path ) );

  return $request_data;
}

My 3rd party API saved correctly the base64 encoded file into the “test” field (I was able to manually decode it and get back my file), however, the other two fields that are file field didn’t accept base64 string. I tried with postman, it accept files, but not base64 string. Is there a way to provide something similar to the upload HTML field to the API?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.