I’ve just started doing some lightweight testing with the API. To begin, I’m mostly just copy/pasting the ruby samples from the v3 docs.
Here is a small snippet of what I’m doing:
agency = Agency.includes(:employees, :influencers, :submissions).find(8)
first_employee = agency.employees.first
body = {
properties: {
name: agency.name,
industry: "INSURANCE",
type: "SUBSCRIBER",
domain: first_employee.email.split(/@/).last,
application_identifier: agency.id,
employee_count: agency.employees.count,
influencer_count: 0,
submission_count: 0,
subscription_status: "none",
}}
url = URI("https://api.hubapi.com/crm/v3/objects/companies?hapikey=#{ENV["HUBSPOT_API_KEY"]}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = body.to_json
response = http.request(request)
puts response.read_body
This fails, and the response is as follows:
{"status":"error","message":"Property values were not valid: [
{\"isValid\":false,\"message\":\"Property \\\"employee_count\\\" does not exist\",\"error\":\"PROPERTY_DOESNT_EXIST\",\"name\":\"employee_count\"},{\"isValid\":false,\"message\":\"Property \\\"influencer_count\\\" does not exist\",\"error\":\"PROPERTY_DOESNT_EXIST\",\"name\":\"influencer_count\"}
]","correlationId":"e600a92f-feea-45a8-958e-0eb293166473","category":"VALIDATION_ERROR"}
So the call failed because employee_count and influencer_count “do not exist”, the thing is, they do. See this screenshot for proof.
In fact, 3 of the other attributes are custom attributes I created at the same time as employee_count and influencer_count and they all work fine.
Anyone’s help in identifying this issue would be greatly appreciated.
