ValidationError: Controller required on post to customers with controller included

I’m POSTing this to “customers” in my sandbox

{
  "type": "business",
  "businessName": "ACME Enterprises",
  "businessType": "corporation",
  "businessClassification": "9ed3813f-7d6f-11e3-8840-5404a6144203",
  "address1": "123 Main St",
  "city": "Nyack",
  "state": "NY",
  "postalCode": "10960-3113",
  "ein": "12-3456789",
  "correlationId": "rtBgjKvttYMctbfD8",
  "firstName": "Account",
  "lastName": "Admin",
  "email": "account.admin@acme.com",
  "controller": {
    "firstName": "Jane",
    "lastName": "Controller",
    "title": "Comptroller",
    "dateOfBirth": "1994-04-28",
    "ssn": "4321",
    "address": {
      "address1": "321 Main St",
      "city": "New York Mills",
      "state": "NY",
      "postalCode": "13417-1226",
      "country": "US"
    }
  }
}

And I get this response:

{
  "status": 400,
  "headers": {},
  "body": {
    "code": "ValidationError",
    "message": "Validation error(s) present. See embedded errors list for more details.",
    "_embedded": {
      "errors": [
        {
          "code": "Required",
          "message": "Controller required.",
          "path": "/controller",
          "_links": {}
        }
      ]
    }
  }
}

I have included the controller, so what’s the issue?

Hi @gfb107, I believe the issue is that within the Controller address object that state needs to be changed to stateProvinceRegion for it to be a valid request. I’ll create a ticket on our end to see if we can update the path to “/controller/address/stateProvinceRegion” to give a better indication of what field is invalid in your request.

Hope this helps, please let us know if you have any follow up questions!

That was it!

1 Like

I just ran into a similar problem, it would be great if the error was more descriptive than just “/controller”.

Thank you for the feedback @r.schmitt. I’m creating a ticket for this.

1 Like

Hi @r.schmitt , do you have an output of the request body that was submitted which returned this error? Or a timestamp and app name I could use to reference this request in our logs? Thanks!

Hi @spencer , sorry but I do not have the full request body anymore, but the problem I had was that my app was sending null values with the ‘address2’ and ‘address3’ parameters for the controller. I simply did not add them into the request if they are null and it started working.
For example, I was sending this:

var requestBody = {
  firstName: 'Jane',
  lastName: 'Merchant',
  email: 'accountAdmin@email.com',
  type: 'business',
  address1: '123 Corrected Address St',
  city: 'Some City',
  state: 'NY',
  postalCode: '11101',
  controller: {
      firstName: 'John',
      lastName: 'Controller',
      title: 'CEO',
      dateOfBirth: '1980-01-01',
      ssn: '1234'
      address: {
        address1: '1749 18th st',
        address2: null,
        address3: null,
        city: 'Des Moines',
        stateProvinceRegion: 'IA',
        postalCode: '50266',
        country: 'US'
      }
  },
  businessClassification: '9ed38155-7d6f-11e3-83c3-5404a6144203',
  businessType: 'llc',
  businessName: 'Jane Corp',
  ein: '12-3456789'
};

and now I am sending this:

var requestBody = {
  firstName: 'Jane',
  lastName: 'Merchant',
  email: 'accountAdmin@email.com',
  type: 'business',
  address1: '123 Corrected Address St',
  city: 'Some City',
  state: 'NY',
  postalCode: '11101',
  controller: {
      firstName: 'John',
      lastName: 'Controller',
      title: 'CEO',
      dateOfBirth: '1980-01-01',
      ssn: '1234'
      address: {
        address1: '1749 18th st',
        city: 'Des Moines',
        stateProvinceRegion: 'IA',
        postalCode: '50266',
        country: 'US'
      }
  },
  businessClassification: '9ed38155-7d6f-11e3-83c3-5404a6144203',
  businessType: 'llc',
  businessName: 'Jane Corp',
  ein: '12-3456789'
};

And now I am not getting any errors since I am omitting null values.

Hope that helps.

1 Like