Can't add new contacts, "property cannot be missing or null"

contacts

#1

Here is my code:

<?php

$propArr = array(
        'properties' => array(
            array(
                "name" => "email",
                "value" => "testingapis@hubspot.com"
            ),
            array(
              "name" => "firstname",
              "value" => "Adrian"
            ),
            array(
              "name" => "lastname",
              "value" => "Mott"
            ),
            array(
              "name" => "website",
              "value" => "http =>//hubspot.com"
            ),
            array(
              "name" => "company",
              "value" => "HubSpot"
            ),
            array(
              "name" => "phone",
              "value" => "555-122-2323"
            ),
            array(
             "name" => "address",
              "value" => "25 First Street"
            ),
            array(
              "name" => "city",
              "value" => "Cambridge"
            ),
            array(
              "name" => "state",
              "value" => "MA"
            ),
            array(
              "name" => "zip",
              "value" => "02139"
            )
        )
    );

    echo "Adding Contact \n\n";
    $endpoint = 'https://api.hubapi.com/contacts/v1/contact/?hapikey=' . $hapikey;
    $ch = @curl_init();
    @curl_setopt($ch, CURLOPT_POST, true);
    $post_json = json_encode($propArr);
    @curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
    @curl_setopt($ch, CURLOPT_URL, $endpoint);
    @curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = @curl_exec($ch);
    $status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $curl_errors = curl_error($ch);
    @curl_close($ch);
    echo "curl Errors: " . $curl_errors;
    echo "\nStatus code: " . $status_code;
    echo "\nResponse: " . $response . "\n\n";
}

And the error message I’m getting:

Response: {“status”:“error”,“message”:“property cannot be missing or null”, etc.}

I’m not sure what property the msg is referring to, have tried to add/remove different properties from the array to no avail.

Thanks


#2

Nevermind, I am dumb. Needed to switch out the “name” property with “property.” Wish there was a way to delete the post, as it’s sort of useless at this point.


#3

@vbhubspotuser I can remove the post for you if you’d like? I’d argue keeping it as others have run into or will run into the same error message at some point and I believe this could help future developers trying to interface with the HubSpot APIs.


#4

@pmanca Sure, we can keep it up. Hopefully it will help others.


#5

Yeah thanks for keeping this up because I had the same "dumb" question!