Gravity Forms to Zapier error

I am encountering a strange problem when using Gravity Forms Pro and Zapier.
I have Zapier AddOn activated and the RESTAPI is connected.

Once i try to load testdata, zapier will show me this error message:
Error code: Error while retrieving: Unexpected token < in JSON at position 0

Has this been fixed before or has anyone a clue what this means? (Yes, i googled it)

1 Like

Are you using the Zapier submit form action? That error is common with that action when the form is configured to use a page or redirect type confirmation.

There is a code snippet after the response section on the following page of the documentation that can be used to prevent Zapier following the confirmation URL: Submitting Forms with REST API v2 - Gravity Forms Documentation

The code can be added to the theme functions.php file, a custom plugin, or a code snippets plugin.

2 Likes

Thank you for your reply!

I added the snippet with a code snippets plugin and changed the confirmation to text-type aswell - just to be 100% sure haha
I`ll monitor the answer in zapier and will get back to this thread later!

2 hours later, sadly still the same error in zapier - I even added the code

add_filter( 'rest_post_dispatch', function ( $response, $server, $request ) {
    if ( $response->get_status() !== 200
         || $request->get_method() !== 'POST'
         || empty( $request['form_id'] )
         || $request->get_route() !== "/gf/v2/forms/{$request['form_id']}/submissions"
    ) {
        return $response;
    }
 
    $headers = $response->get_headers();
    unset( $headers['Location'] );
    $response->set_headers( $headers );
 
    return $response;
}, 10, 3 );

to the functions.php in the FTP
I am not big into code, is this even correct like this?

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