Connecting Webhooks to accelo API for attachments

Hello,

I am using the the GF Webhooks add-on to connect to the Accelo API, which needs attachments to be sent in the same way that a web browser would POST the attachment. I am wondering how to allow the attachments to be sent via POST and not URL?

Hello. To send files via the Webhooks Add-On, you can use the gform_webhooks_request_data filter in the theme functions.php file or a custom functionality plugin to modify the data before the request is sent. The file needs to be base64_encoded

You can use a line like this with the above filter to get the file contents, encode it, and add it to the request.

$request_data['filedata'] = base64_encode( file_get_contents( $file_path ) );

If the file is uploaded via a file upload field you can use the following line to get the file path, replacing 1 with the ID of the field:

$file_path = GFFormsModel::get_physical_file_path( rgar( $entry, 1 ) );

We have the attachment now getting set as base 64 encode but it still does not attach to the email that gets sent using the Webhook to Accelo. We were able to see the data from the request in the logs and it attaches like the other data

But when you view the email in gmail, it does not show the attachment.

. Is there a special array key that we need?

Hello. Is that email being sent by Accelo or Gravity Forms?

Assuming the email is generated by Gravity Forms, you may need to do some additional customization via gform_notification to get the now base 64 encoded file back into a format that your outgoing email system can process.

This is one of the reasons that I am continually amazed at the flexibility that Gravity Flow’s outgoing webhook provides. You can keep the field(s) of data in whatever format you need for WP/Gravity Forms, and each webhook step can be adjusted to suite whatever API you are connecting to. In that doc link above, example 7 shows how we turn a standard file upload field into a true multipart/form-data POST. Perhaps it will give you some code hints towards solving with the approach you sound like you are close to completion with now.

Cheers,
Jamie

Hello,

The email is getting sent by Gravity forms and received via webhook to Accelo.

Hi @links. I don’t follow. Gravity Forms sends an email notification: where is that sent, and then what happens?

We send an email notification via Gravity forms and then use the webhook on Gravity Forms to connect to the webhook API. We are using the Sage 9 Theme but we are unable to get the current step. You can view the site Support – Links Web Design

© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.