APIs & Integrations

jasond1
Member

Create a Company Property - API

I am trying to create a company property using the API, but am getting the message message: 'name can not be null or empty' Any ideas?

 
 var request = require("request");
  var options = { method: 'POST',
    qs: { hapikey: '96fdcb0c-a9b6-4db4-ac9e-56703ab1fca4' },
    headers: 
     {'Content-Type': 'application/json' },
    body: 
     { properties: 
        [ { name: 'name',         value: 'redflag_company_number' },
          { name: 'label',        value: 'Company Number'         },
          { name: 'groupName',    value: 'companyinformation'     },
          { name: 'type',         value: 'string'                 },
          { name: 'fieldType',    value: 'text'                   },
          { name: 'description',  value: 'Company Number'         } ] },
    json: true };
 

  request(optionsfunction (errorresponsebody
  {
      if (errorthrow new Error(error);
      console.log(body);
  });
 
0 Upvotes
1 Reply 1
WendyGoh
HubSpot Employee
HubSpot Employee

Create a Company Property - API

Hey @jasond1,

 

When looking to create a company property using the Create a Company Property | Company Properties API the POST body should follow a similar structure like this:

 

{
  "name": "another_example_property",
  "label": "Another Example Property",
  "description": "Another property being created as an example.",
  "groupName": "companyinformation",
  "type": "string",
  "fieldType": "text"
}

Looking at your code, it looks like you have included { properties with an array of the field. 

 

Could you remove the properties array and see if it works?

0 Upvotes