API Help
I’ve been following your API v2 guides and snagged the PHP sample listed here:
https://github.com/WildApricot/ApiSamples/blob/master/PHP/sampleApplication.php
I was able to properly implement the getAccountDetails function and I created a getContactIdFromEmail function that tweaked the getContactsList function to filter on an email address.
Now I’m trying to update the FirstName of the Contact that I received. Here’s the code:
function updatePasswordByContactId($contactId, $email)
{
global $waApiClient;
global $accountUrl;
$url = $accountUrl . "/Contacts/Contact/{$contactId}";
$data = array("FirstName" => "Chaz2");
$result = $waApiClient->makeRequest($url, "PUT", $data);
return true;
}
I analyzed the CURL parameters to see that it is calling the URL:
https://api.wildapricot.org/v2/Accounts/73659/Contacts/Contact/25710546 ALIDCONTACTID
In a “PUT” with the following JSON data:
{"FirstName":"Chaz2"}
I tried using “First name”, “Email”, and “e-Mail” and nothing seems to work.
It simply will return an empty string which gets JSON decoded to NULL.
Help!
-Chaz
The help has been updated.
-
Steve Andrews commented
Thanks Matthew for pointing this out. The help has been updated:
-
Matthew Thomure commented
The documentation is wrong.
Where it says:https://api.wildapricot.org/v2/Accounts/VALID_ACCOUNT_ID/Contacts/Contact/VALID_CONTACT_ID
You need to say:https://api.wildapricot.org/v2/Accounts/VALID_ACCOUNT_ID/Contacts/VALID_CONTACT_ID
Otherwise you receive a 404 error.
You can add this code to your request function after you run curl_exec() for debugging purposes. This will show the HTTP status code of your request.
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);echo $status;
- Matthew -
Evgeny Zaritovskiy commented
-
tinskey commented
I also tried adding "ContactID" and "ID" (with the ContactID) into the $data array. Same thing.