Invalid Email Address when adding a person

I'm having trouble adding a person to the account via the API. It seems no matter what email address I try it always returns Code: 1 - Invalid Email Address.

I've checked my scripts output the to API and it comes out as a string "my@email.com".

Everything else also comes out correctly formatted and Client creation works along with billing options, but adding a person fails every time.

Details:
HTTP Response: 400

API Response: O:8:"stdClass":2:{s:4:"Code";i:1;s:7:"Message";s:21:"Invalid Email Address";}

jamesd jamesd, 4 years ago

Could you provide the code you're using which causes the error shown? Without that, there's not much anyone can help you with. Thanks.

aphexone, 4 years ago

Sorry, here are some code examples:

The 'Add a person' function was missing from the API wrapper so I've created a new function to add the new person called set_people. In csrest_clients.php I've added this function:

function set_people($client_people) {
        return $this->put_request($this->_clients_base_route.'people.json', $client_people);
    } 

Here is an example of the code I'm using to pass my input to the API via set_people:

$new_client_user_wrap = new CS_REST_Clients($clientid, $apikey);
        $new_client_user_result = $new_client_user_wrap->set_people(array(
                'EmailAddress' => 'test@email.com',
                'Name' => 'testuser',
                'AccessLevel' => 1023,
                'Password' => 'password',
            ));
}

I have a debug function inside _call() that logs the value of $call_options['data'] after it has been serialised, to a DB table and it comes out like this:

{"EmailAddress":"test@email.com","Name":testuser","AccessLevel":1023,"Password":"password"}

That is then what goes into the API, which responds with HTTP 400 : O:8:"stdClass":2:{s:4:"Code";i:1;s:7:"Message";s:21:"Invalid Email Address";}

I have also tried urlencoding() the email address before it goes in but that doesn't work either and gives the same result.

jamesd jamesd, 4 years ago

There is a CS_REST_People class you should be using to add people. If you don't see that in your local version of the PHP wrapper, you're using a very old version.

Please grab the latest version from here to use in your app.

It's important to subscribe to the API Announcements forum topic to keep up to date with regular API and wrapper updates. For example early next week there will be an announcement of updates and new functionality we will be releasing.

Hope that helps.

aphexone, 4 years ago

ahh thanks, I didn't see the people class. I was going off the Client section of the API documentation so I assumed it was part of the Client class.

Found the right method and it's fixed my issue, thanks for the help.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098