Highrise API Returning Error Code 500

387 views Asked by At

I am attempting to use the PHP Wrapper for the Highrise API located here:

https://github.com/ignaciovazquez/Highrise-PHP-Api

I need to set a custom field for a HighrisePerson object. According to the code this should be pretty straightforward...

$person->setCustomField("Field Name", $value); // Pulled almost straight out of the documentation

Unfortunately when I try to save this back to highrise using $person->save(); I get the following error:

Uncaught exception 'Exception' with message 'API for Person returned Status Code: 500 Expected Code: 200'

So the error isn't in the code... Highrise just isn't accepting the custom field. Any ideas as to why this is?

2

There are 2 answers

0
Matthew Jones On BEST ANSWER

Ok... I figured it out...

In the API the following:

$person->setCustomField("Field Name", $value);

creates a new custom field within Highrise. So if there isn't already a custom field named "Field Name" it would create it. If that field already exists, it returns the 500 error.

To the best of my knowledge there's no way to set the value of an existing field using that wrapper. You can only create new fields, which is kind of jank.

I found a fork off that wrapper that's working pretty well for me. It's hosted here: https://github.com/AppSaloon/Highrise-PHP-Api

The usage in this one is confusing and took me a while to figure out.

Basically you want to do a search for all the custom fields in Highrise. Once you find the one you want, you assign it the requisite value... So the code looks like this:

// Load up all the custom fields out of Highrise
    $cfields = $highrise->findAllCustomfields();

// Search each custom field until we find the "Field Name" one. When we do, add it to our Highrise Person.
    foreach ($cfields as $c) {
        if ($c->getSubjectFieldLabel() == "Field Name") 
        {
            // Assign that custom field to the person
            $highrisePerson->addCustomfield($c, "Field Value");
        }
    }

I hope this helps someone else down the road who runs into the same issue. I discovered the forked PHP wrapper from another Stack Overflow question, but they were never able to get custom fields to work either.

2
Hüseyin BABAL On

In order to use 37signals throught Highrise-PHP-Api, you should provide an account name and access token;

$hr = new HighriseAPI();
$hr->setAccount("accountname");
$hr->setToken("token");

and then you can execute your other functions

$person->setCustomField("Field Name", $value);

If you carefully look at tests for this api, you will see;

if (count($argv) != 3)
        die("Usage: php users.test.php [account-name] [access-token]\n");