Forms API now returning formFieldGroups null instead of empty array


#1

I just wanted to plead with you not ever to repeat switching from returning empty arrays to null values.
We’ve happily done empty checks on arrays and left out those pesky null checks.
Today, all sites integrated with the Forms API stopped working due to the new null value.

Please keep using empty value types instead of null values.


#2

Hi @Lars-Erik

Is there a specific form that you saw this with? Was this a newly created form or an existing form where the response changed? Looking at a couple example forms I’m seeing that as an empty array for forms without an fields, and I wasn’t able to find any cases where that property was null:
"formFieldGroups" : [],


#3

Several untouched existing forms have started to return null instead of [].
I’ll dig up portals and form IDs tomorrow.
I think most of them don’t use field groups, but we’ve been testing for an empty array instead of null. All our sites blew up today due to the array being null instead. We didn’t change anything.


#4

I couldn’t let it rest. The schema has apparently changed overnight.

Calling this URL:
https://api.hubapi.com/contacts/v1/forms/a2c2baf3-c3ed-4dc1-a556-c23c6830bde6?hapikey=xxxx
on portal 436498, yields the following for form field groups:

"leadNurturingCampaignId": "",
"formFieldGroup": [
{
    "name": "group-0",
        "fieldName": [
        "firstname",
        "lastname"
    ],
    "default": true
},
{
    "name": "group-1",
    "fieldName": [
        "email"
    ],
    "default": true
},

The documentation doesn’t seem to agree entirely with itself on the schema today. For all forms, this is supposed to be returned:

"formFieldGroups": [
  {
    "name": "group-0",
    "fieldNames": [
      "firstname"
    ],
    "default": true
  },

While for a single form, this should’ve been returned:

"formFieldGroups": [
    {
        "fields": [
            {
                "name": "firstname",
                "label": "First Name",
                "type": "string",
                "fieldType": "text",
                "description": "",
...

And in the latter, there’s no outer “fields” array at all.

So I take back my original plea about changing from arrays to nulls. I should’ve guessed it was Newtonsoft JSON that nulled out stuff it couldn’t deserialize.
We deserialize to the schema documented on the “get all forms” page.
New wish: don’t change the schema on the same version endpoint overnight. :wink:


#5

Never mind the doc references above. They’re from v2. We haven’t upgraded the code from v1. So the schema change must’ve happened with v1. (Which lacks said docs. on formFieldGroups)


#6

At least it gave me the inspiration for a blog post. :slight_smile:

http://blog.aabech.no/archive/musings-on-null-objects-schemas-and-upgrades/


#7

@Lars-Erik I talked to our forms team, and it looks like there was a change that would have affected the v1 endpoints. I’d definitely recommend updating to use the v2 endpoint, since the v1 endpoints have been deprecated for over a year at this point, and but we are going to fix this. I’ll also get the documentation for the v2 endpoint fixed as well.


#8

Great. I’ve realized all the forms lost their layout with the missing group info.
We’ll have to update it ASAP, unless a fixed v1 endpoint is rolled out tomorrow.
Would be nice to have a little longer grace period, although it seems we’re one of the last upgrading.


#9

Any ETA on the rollback?


#10

It’s being worked on today, we expect this to be fixed and live tomorrow.


#11

Great, thanks!

Vennlig hilsen

Lars-Erik Aabech
Faglig leder utvikling
MarkedsPartner AS


+47 920 30 537