BlogGravityWP – API Connector 1.4.3: Send JSON POST Requests from Gravity Forms to Google Sheets

GravityWP – API Connector v1.4.3 makes it easier to connect Gravity Forms to modern APIs that expect a structured JSON request body

The main improvement in this update is support for JSON body format in POST feeds. This means you can now send data from a Gravity Forms submission as application/json, including nested values such as arrays and objects.

That is useful for APIs like Google Sheets, CRM platforms, booking systems, accounting tools, and custom REST endpoints.

In this article, we will show what changed and walk through a practical example: sending a Gravity Forms submission to the Google Sheets API.

What is new in GravityWP – API Connector 1.4.3?

Version 1.4.3 introduces three practical improvements:

1. POST feeds now support a new JSON body format. Instead of only sending regular form parameters, you can map form fields to JSON paths such as:

customer.name
items[0].sku
values[0][0]

2. the API connection settings screen is easier to understand. Field labels and descriptions have been improved, so it is clearer where to enter details such as the Base URL, authentication method, API key, bearer token, or OAuth settings.

3. OAuth 2.0 Authorization Code connections now show the Redirect URL directly in the settings screen, including a Copy button. This makes it easier to configure OAuth providers that require an exact callback URL.

What can you achieve with JSON body support?

Many APIs expect data in JSON format. A simple API request might look like this:

{
  "name": "Jane Doe",
  "email": "jane@example.com"
}

Earlier versions of API Connector already supported this. However, many real APIs require a nested structure:

{
  "customer": {
    "name": "Jane Doe",
    "email": "jane@example.com"
  },
  "items": [
    {
      "sku": "ABC-123",
      "quantity": 2
    }
  ]
}

Before this update, building this type of request often required custom code. Now you can create many of these structures directly in the feed settings.

Practical example: send Gravity Forms submissions to Google Sheets

A good real-world use case is the Google Sheets API.

Google’s spreadsheets.values.append method appends values to a spreadsheet. The endpoint uses a POST request and requires a spreadsheet ID, a range, and a valueInputOption query parameter. The request body contains a ValueRange, which uses a values array. (Google for Developers)

That makes Google Sheets a strong example for the new JSON body feature, because the request body needs nested array data.

Example goal

Imagine you have a Gravity Forms contact form with these fields:

Name
Email
Message

You want each form submission to be added as a new row in a Google Sheet.

The JSON body sent to Google Sheets should look like this:

{
  "values": [
    [
      "Jane Doe",
      "jane@example.com",
      "I would like more information."
    ]
  ]
}

In GravityWP API Connector 1.4.3, you can build this structure with JSON path mappings:

values[0][0] → Name
values[0][1] → Email
values[0][2] → Message

The values[0] part represents the first row. The second index represents the column inside that row.

How to connect Gravity Forms to Google Sheets

Step 1: Create a Google Sheets API connection

In WordPress, go to:

Forms → Settings → API Connector Create a new API connection.

Use these settings:

API Name: Google Sheets
Slug: google-sheets
Base URL: https://sheets.googleapis.com
Authentication method: OAuth 2.0 (Authorization Code)

For the OAuth scope, use:

https://www.googleapis.com/auth/spreadsheets

Google lists this as one of the accepted OAuth scopes for appending values to a spreadsheet. (Google for Developers)

Copy the Redirect URL shown in the GravityWP API Connector settings and add it to your Google Cloud OAuth client configuration. The Redirect URL must match exactly.

Step 2: Create an API Connector feed

Open your Gravity Form and go to:

Form Settings → API Connector Add a new feed.

Use these feed settings:

API Configuration: Google Sheets
Request Method: POST
Body format: JSON body
Endpoint URL: /v4/spreadsheets/YOUR_SPREADSHEET_ID/values/Sheet1!A:C:append?valueInputOption=USER_ENTERED

Replace: YOUR_SPREADSHEET_ID with the actual spreadsheet ID from your Google Sheet URL.

The range in this example is: Sheet1!A:C
Google uses the range to find the table and append the values after the last row. (Google for Developers)

Step 3: Map your Gravity Forms fields to the JSON body

In the request body parameter mapping, add:

values[0][0] → Name
values[0][1] → Email
values[0][2] → Message

This tells API Connector to create a JSON body with one row and three columns.

For example, this form submission:

Name: Jane Doe
Email: jane@example.com
Message: I would like more information.

becomes this JSON body:

{
  "values": [
    [
      "Jane Doe",
      "jane@example.com",
      "I would like more information."
    ]
  ]
}

Step 4: Submit the form

When the form is submitted, GravityWP API Connector sends a POST request to the Google Sheets API.

The request appends the form values to the next available row in your selected range. Google’s append method writes the values after the last row of the detected table. (Google for Developers)

When should you use JSON body format?

Use JSON body when the API documentation asks for:

Content-Type: application/json

or when the example request body in the API documentation is shown as JSON.

Typical examples include:

{
  "email": "jane@example.com"
}

or:

{
  "customer": {
    "name": "Jane Doe"
  }
}

or:

{
  "values": [
    [
      "Jane Doe",
      "jane@example.com"
    ]
  ]
}

Use Form parameters when the API expects regular key-value form data instead of JSON.

JSON mapping examples

Here are a few common mapping patterns.

Simple object

name → Name
email → Email

Creates:

{
  "name": "Jane Doe",
  "email": "jane@example.com"
}

Nested object

customer.name → Name
customer.email → Email

Creates:

{
  "customer": {
    "name": "Jane Doe",
    "email": "jane@example.com"
  }
}

Array of objects

items[0].sku → Product SKU
items[0].quantity → Quantity

Creates:

{
  "items": [
    {
      "sku": "ABC-123",
      "quantity": "2"
    }
  ]
}

Google Sheets row

values[0][0] → Name
values[0][1] → Email
values[0][2] → Message

Creates:

{
  "values": [
    [
      "Jane Doe",
      "jane@example.com",
      "I would like more information."
    ]
  ]
}

Developer option: modify the final JSON body

Developers can also modify the generated JSON body before the request is sent by using the new filter:

gravitywp_api_connector_json_request_body

Example:

add_filter(
    'gravitywp_api_connector_json_request_body',
    function ( $body, $feed_settings, $entry, $form ) {
        $body['metadata'] = array(
            'source'  => 'gravity-forms',
            'form_id' => rgar( $form, 'id' ),
        );
        return $body;
    },
    10,
    4
);

This is useful when an API requires extra metadata, a wrapper object, or a slightly different structure than the one configured in the feed settings.

Summary

GravityWP – API Connector 1.4.3 makes Gravity Forms API integrations more flexible by adding support for JSON body format in POST feeds.

The Google Sheets example shows why this matters. The Sheets API expects a structured JSON body with a values array, and version 1.4.3 lets you create that structure directly with mappings like:

values[0][0]
values[0][1]
values[0][2]

For site builders, this means fewer custom snippets. For developers, it means a cleaner base to extend. For clients, it means faster and more reliable integrations between Gravity Forms and the tools they already use.

Proudly powered by WordPress