How can we make it easier for you to develop on top of Wild Apricot?

API PUT produces unexpected result

As part of our first operational use of the API, I need to update two fields dynamically. For trials, I am using php cUrl, modeled on your sample application. I have no problems with GET, but PUT leaves me baffled.

Each time I run the script, the target fields are not changed - but the membership of the target contact goes from "active" to "membership not allocated".

Clearly my code is doing this: but how/why? Can anyone give me a clue as to what is happening?

Also, my debugging script shows a result JSON containing all the target contact's data. Is this as it should be? And can it be prevented (unnecessary data traffic, etc.)?

My cUrl code is (sorry about the bad formatting below):

$accountUrl = "https://api.wildapricot.org/v2/accounts/[account]/Contacts/";
$queryParams = array(
'Id' => $contact,
'Field values' => array(
0 => array(
'FieldName' => "fieldname1",
'Value' => 'XXXXX'
),
1 => array(
'FieldName' => "fieldname2",
'Value' => 'XXXXXX'
)
)
);
$url = $accountUrl.$contact;
$verb = "PUT";

$ch = curl_init();
$headers = array(
'Authorization: Bearer ' . $token,
'Content-Type: application/json'
);
curl_setopt($ch, CURLOPT_URL, 'https://api.wildapricot.org/v2/accounts/[account]/Contacts/[contact]');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $verb);
if ($queryParams) {
$jsonData = json_encode($queryParams);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
}

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$jsonResult = curl_exec($ch);
if ( !$jsonResult ) {
echo curl_errno($ch) . ': ' . curl_error($ch);
}
curl_close($ch);

0 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Hamish McCallumHamish McCallum shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    6 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base

      Wild Apricot Inc. 144 Front Street West Suite 725, Toronto, Ontario, Canada M5J 2L7