Hi everyone,
if have a PHP scrpt (behind a custom "add new member" form on a custom website) which shall now add the new member to Webling using a POST command (script below).
I read through https://demo.webling.ch/api/1#member-member-list-post and step-by-step succeeded in getting to the point where all data seems to be correct (no "wrong field" warning anymore) and API key is accepted (no "apikey warning" anymore).
The only thing that's missing is PARENT. Error message is "Invalid key in update data: parent".
The point is: I could not find any info on how to set the parent. I mean: what exactly should be the parent? A "group"? But which "parent id" to use? I tried to read "/api/1/membergroup?format=full" and look for the id of the group I want to add that new member. In my system, this happens to be "id":7448. I tried this as parent but I am still getting the error.
I am a bit lost in this and appreciate your help!
Question: what to use as "parent" when adding a new member through POST?
Here is my script:
`
$url = 'https://<meinverein>.webling.eu/api/1/member';
$fields = array(
"type" => "member",
"readonly" => false,
"parent" => "7448",
"properties" => $weblingProps,
);
$fields_json = json_encode($fields, JSON_PRETTY_PRINT);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["apikey: ".$weblingkey]);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_json );
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
`
Result is:
{"error":"Invalid key in update data: parent"}
Best regards,
Kai